Skip to main content

Langfuse

Fanar uses Langfuse for two things: prompt management and workflow tracing.

warning

Langfuse is required, not optional. Agents fetch their prompts from Langfuse at construction time and raise an error if it is disabled or unconfigured. An instance without Langfuse credentials can serve queries and dashboards, but the AI features will fail.

Environment variables

LANGFUSE_ENABLED=true
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://lf.fanar.tech

LANGFUSE_BASE_URL defaults to https://lf.fanar.tech. Point it at your own Langfuse instance if you self-host one.

Prompts

Each agent node fetches its prompt from Langfuse by name. Every node also ships a fallback_prompts.py next to it, used when the managed prompt cannot be resolved.

This means prompt changes can be made and rolled out from Langfuse without redeploying Fanar — but it also means Langfuse availability is on the critical path for the agent.

Tracing

When enabled, agent workflow steps are traced to the configured Langfuse project, which is the primary tool for debugging why the agent produced a particular answer.

Choosing models per node

Each agent node resolves its model from an environment variable named after its config prefix, <PREFIX>_MODEL_NAME, falling back to app config and then a built-in default.

PrefixUsed by
INTENTIntent detection, query search, semantic layer routing
SQL_GENERATIONSQL generation and data source selection
ANSWER_GENERATIONChat answer generation, dashboard widget feasibility
ANSWER_GENERATORCopilot answer generation
VISUALIZATIONVisualization generation and editing
COPILOTCopilot query editing
QUERY_SEMANTICSaved-query semantic index descriptions

So SQL_GENERATION_MODEL_NAME=gpt-5 overrides the SQL generation model, and SQL_GENERATION_MODEL_TEMPERATURE its temperature.

OpenAI, Anthropic and Mistral model names are all recognised and routed to the right client automatically.