> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ibex.ajna.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Ibex Agent Engine

> Node.js LLM runtime and workflow orchestration engine.

# Ibex Agent Engine

The `ibex-agent-engine` is the operational brain powering the AI functionality across the data platform. Built in Node.js, it executes multi-step reasoning pipelines that combine Large Language Model actions with physical SQL execution.

## Architectural Role

This service runs strictly inside the internal Docker `ajna` network on port `3000`. It is **not exposed** to the internet via Traefik. It acts exclusively as a secure worker invoked by the `ibex-ai-service`.

## High-Level Working

Each agent running on the engine is defined as an execution pipeline composed of discrete tool nodes. A standard workflow to answer a user's analytical question looks like this:

1. **Information Retrieval (`tool-kb-1`)**: The agent engine searches the RAG knowledge base for context regarding table schemas and business documentation.
2. **SQL Generation & Execution (`tool-exec-1`)**: The engine calls out to OpenRouter (`https://openrouter.ai/api/v1`) using `OPENROUTER_API_KEY` to generate the SQL query. It then routes this physical SQL to the internal `ibex-analytics-service` and awaits the results.
3. **Natural Language Generation (`tool-gen-1`)**: The engine makes a final LLM call to format the raw database records into a conversational response.

The pre-defined standard agent, `demo_data_analyst`, is hosted here, bridging the gap between natural language requests from the BI UI and DuckDB federated query results.
