Skip to content

Agent

The agent configuration defines the core settings for your Datus Agent, including the target model selection and all available LLM providers that can be used throughout the system.

Configuration Structure

Logging

Configure process logging in agent.yml:

agent:
  logging:
    level: INFO     # DEBUG, INFO, WARNING, ERROR, CRITICAL; case insensitive

The level priority is explicit --log-level / --debug → DATUS_LOG_LEVEL → agent.logging.level → INFO. --debug means --log-level DEBUG; specifying both is an error. For example, datus-api --config conf/agent.yml --log-level WARNING applies WARNING to both API and Agent business logs. The CLI, API, Gateway, MCP server, web chatbot, and benchmark entrypoints share this resolution. API workers inherit the selected level; rebuilding an Agent does not reset it. Embedded applications can call configure_logging(agent_config=config) at startup.

The file handler enforces the selected threshold even for third-party loggers. Existing third-party noise suppression remains. Log files use plain text with event fields rendered as key-value pairs; interactive console output writes to stderr. Logging is independent of tracing. Optional agent.logging.redact accepts enabled, fields, and regex patterns, with credential-field redaction enabled by default. See model-call and tool observability for the collected events and trace controls.

LLM Configuration (Two-Tier Provider Model)

LLM selection uses a two-tier system. Most users only need the provider-level configuration; custom entries are for self-hosted or private endpoints.

Provider-Level Configuration (Preferred)

Configure credentials under agent.providers.<name>. Available models and metadata are refreshed automatically from OpenRouter, with conf/providers.yml as an offline fallback. Use the /model slash command in the CLI to switch between providers and models interactively.

agent:
  providers:
    openai:
      api_key: ${OPENAI_API_KEY}
    deepseek:
      api_key: ${DEEPSEEK_API_KEY}
    claude_subscription:
      auth_type: subscription
    codex:
      auth_type: oauth

Only credentials need to be specified — type, base_url, and model lists are inherited from conf/providers.yml.

Custom / Legacy Models

For self-hosted or private-deployment models not covered by providers.yml, use agent.models:

agent:
  models:
    my-internal:
      type: openai
      base_url: https://internal.example.com/v1
      api_key: ${MY_KEY}
      model: internal-gpt-4

Custom entries appear under the Custom tab in /model and can be activated with /model custom:my-internal.

Target Model Selection

The active model is determined by project-level override (.datus/config.yml) or the base agent.target field. The /model command writes to the project override automatically.

Project-Level Override (.datus/config.yml)

The /model command persists selections to .datus/config.yml in the current working directory:

# Provider-level selection
target:
  provider: openai
  model: gpt-4.1

# Or, custom model selection
target:
  custom: my-internal

Legacy Target (backwards compatible)

The agent.target field in agent.yml is still honored when no project-level override exists:

agent:
  target: openai  # Legacy: key from agent.models section

Resolution order: .datus/config.yml → agent.target.

Response Language

language is an optional field that pins the natural language used by every agentic node for user-facing outputs — replies, summaries, clarifying questions, sub-agent prompts issued via task, and prose written into files. Code, SQL, identifiers, file paths, URLs, and JSON keys stay in their original form regardless of the setting.

When omitted, no directive is injected into the system prompt and the model picks its own response language per turn.

agent:
  # Leave it out entirely to let the model decide.
  # Set a code to pin every agentic node to that language.
  language: zh   # Common codes: en, zh, ja, ko, es, fr, de, pt, ru, it

Built-in code → name mapping (injected into the system prompt): en → English, zh / zh-cn → Chinese, zh-tw → Traditional Chinese, ja → Japanese, ko → Korean, es → Spanish, fr → French, de → German, pt → Portuguese, ru → Russian, it → Italian. Unknown codes are used verbatim.

For every mapped code the directive is also restated in that language, next to the English name line — a lone English meta-instruction competes with dozens of turns of English schema/SQL tool output, and smaller models drift out of it. Unknown codes keep the English line only.

Chat API requests can override this per task by sending a language field in the request body (see Chat API). CLI usage inherits the yaml default.

Models Configuration (Custom Entries)

The agent.models section is used for self-hosted or private-deployment LLM endpoints. For standard providers (OpenAI, DeepSeek, etc.), use agent.providers instead.

Required Parameters per custom entry:

  • Entry key (models.<key>) — Logical identifier, referenced by target: {custom: <key>} or node model fields
  • type — Interface type (openai, claude, deepseek, kimi, gemini, minimax, glm, codex, openrouter)
  • base_url — API endpoint URL
  • api_key — API key (supports ${ENV_VAR} substitution)
  • model — Model name / SKU
  • ssl_verify (optional) — TLS verification for this endpoint: true (default), false to disable (discouraged), a path to a CA-bundle PEM, or the CA certificate content inline (a value starting with -----BEGIN CERTIFICATE-----) to trust a private/self-signed gateway CA. Takes priority over the SSL_VERIFY / SSL_CERT_FILE environment variables. See Private or self-signed certificates.
agent:
  models:
    my-internal:
      type: openai
      base_url: https://internal.example.com/v1
      api_key: ${MY_KEY}
      model: internal-gpt-4

Environment Variables

Use environment variables to securely store API keys and other sensitive information:

# Recommended: Using environment variables
api_key: ${YOUR_API_KEY}

# Not recommended for production
api_key: "sk-your-actual-key-here"

Context capacity and large tool results

Each model request reserves its maximum output and a safety margin of max(2048, ceil(context_length * 0.05)). All three settings below are optional; existing configurations do not need new fields:

Setting When omitted
context_length Use existing model specifications or the provider catalogue; fall back to a 1048576 (1M) token budget if unknown
max_tokens Retain the known output default, or use 384000 if unknown, matching the bundled DeepSeek V4 Flash budget. Defaults leave room for input and the safety margin, so small windows may get a lower output budget
tokenizer_ref Use LiteLLM counting for known OpenAI models; otherwise reserve UTF-8 bytes, including for private aliases, without downloading a tokenizer

For an unknown model on a custom OpenAI endpoint, 384000 remains a local reservation. When no output limit is configured or known, Datus omits the output limit from requests and lets the server choose its default. Explicit per-model or per-call limits and known output defaults are still sent. Native protocols that require an output limit retain it.

Model selection and runtime capacity checks share an automatically refreshed OpenRouter catalog. On first use, Datus reads the cache under the current Agent home (cache/openrouter_models.json) or fetches the public catalog with an 8-second timeout. Metadata stays fresh for 10 minutes; failed refreshes retain stale data and wait 60 seconds before retrying. Both context and output limits are retained. Async generation and model listing refresh metadata in a worker thread; capacity lookups on the event loop only read the current cache snapshot. Explicit settings take priority over catalog metadata, with providers.yml and LiteLLM specifications as offline fallbacks. Numeric model versions do not inherit an older version's limits through prefix matching. An advertised output ceiling does not automatically increase the default output budget: known defaults are retained, and newly discovered models keep the 384000 default, lowered when the catalog or remaining context requires it. Public catalog limits describe the catalog's serving provider. On custom endpoints, these limits are planning hints and cannot reject explicitly configured output limits.

The fallback window is a local budget assumption, not automatic detection of server capacity. Private deployments can override any of these settings. Set the actual limit for a smaller window; a larger configured window or a matching tokenizer can improve capacity utilization:

agent:
  models:
    warehouse_llm:
      type: openai
      base_url: https://llm.example.com/v1
      api_key: ${LLM_API_KEY}
      model: warehouse-model
      context_length: 262144
      max_tokens: 8192
      tokenizer_ref: /opt/model/tokenizer.json

context_length and max_tokens must be positive integers. A per-call output limit overrides the configured default. tokenizer_ref accepts a local Hugging Face tokenizer JSON, a Hugging Face tokenizer reference, or tiktoken:<encoding> when that encoding matches the deployment. Local files must be readable by the Datus process. Omitted settings use defaults; explicitly invalid numeric settings still produce an error. An unavailable tokenizer falls back to an available model counter or UTF-8 byte estimation, recording the fallback reason in logs. Failed tokenizer initialization is remembered for up to five minutes across capacity checks, then retried, so repeated planning checks do not repeat the same download failure. Local counting includes serialized messages, instructions, tools and output schemas, plus framing allowance; a deployment with different templates or routing limits can still reject a request and should be configured accordingly. UTF-8 byte estimates can trigger compaction earlier and are not measured provider token usage. Custom endpoints and models without catalog metadata can send requests above an estimated planning budget. Trusted counts are retained separately: if the trusted portion alone exceeds an explicit deployment limit, adding unmeasurable media does not disable that limit. Known standard provider endpoints retain their existing context checks and catalog output ceilings. Images use an available image counter, or a 4096-token estimate per image. Remote image references and opaque files also receive a 4096-token estimate per item when their content cannot be counted. Binary data is excluded from text estimation, and the original request content and references are preserved. These estimates do not require model registration and are not assertions about the server's actual limits.

In the OpenAI-compatible and native OpenAI Responses paths, an explicit output-limit termination is reported as a failure. Tool runs retain received assistant text and usage in the failed result and session; reasoning is not returned as the answer, and incomplete tool calls are not executed. Datus does not automatically retry these runs. Continue with the existing session when more output is needed.

Tools own their result sizes. Agent calls to list_tables, list_databases, list_schemas, query_metrics and select_records default to 200 items per page; query_lineage defaults to 100. page_size is caller-controlled with no hard maximum. Continue directory/lineage results with the original tool, snapshot_id, offset and (for lineage) section. Continue metric/record results with the original tool, result_id and offset; this reads the cached rows without rerunning SQL. For catalog/lineage pages with has_more=true, use offset=extra.next_offset; extra.offset identifies the current page. Business limit remains independent of page size. Direct Python/MCP calls without pagination arguments retain their existing complete catalog/graph or compressed query preview. execute_sql and execute_reference_template keep their existing compression.

There is no read_tool_result tool or generic result projection. Historical archive references are recovered into files readable through read_file in line ranges. Source truncation and analysis completeness are independent of pagination. Disabling agent.compact does not disable the final capacity check; an input that still cannot fit is stopped before sending it to the provider. Page sizes count whole records, not tokens or bytes, and are not automatically reduced. A page of very wide records can therefore still hit the capacity check.

The Codex subscription transport has no output-limit field in its wire protocol. It retains that protocol and reserves the known model output ceiling, including provider catalogue metadata, rather than pretending a smaller requested cap is enforced. Standard API transports send the resolved output limit explicitly.

Private or self-signed certificates

When pointing Datus at an internal LLM gateway or staging endpoint whose TLS certificate is signed by a private CA (one not in the public trust store), requests fail with:

litellm.InternalServerError: AnthropicException - [SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed: self-signed certificate in certificate chain

The cause is that Python's bundled certifi trust store only contains public CAs — it does not read the OS trust store — so a private CA is never trusted automatically. Point Datus at the CA bundle instead of disabling verification:

agent:
  models:
    claude-staging:
      type: claude
      base_url: https://ai.internal.example.com
      api_key: ${ANTHROPIC_API_KEY}
      model: claude-3-7-sonnet
      ssl_verify: /etc/ssl/internal-ca.pem   # trust the private CA; verification stays ON

ssl_verify also accepts the CA certificate content inline (any value starting with -----BEGIN CERTIFICATE-----), so a private CA can be supplied without a file on disk — useful when the config is generated (e.g. from a database) rather than deployed alongside a .pem:

      ssl_verify: |
        -----BEGIN CERTIFICATE-----
        MIIB...snip...IDAQAB
        -----END CERTIFICATE-----

The native client loads inline content into an in-memory trust store; the litellm code path spills it to a temp file in a private per-process directory (it only accepts a CA bundle by path).

Resolution precedence (first match wins):

ssl_verify (agent.yml)  →  SSL_VERIFY env  →  SSL_CERT_FILE env  →  certifi default
  • ssl_verify is the project-level setting and takes priority over the env vars.
  • The standard SSL_CERT_FILE / SSL_VERIFY environment variables work as a no-config alternative (e.g. when IT provisions the CA path machine-wide).
  • To extract a server's CA chain: openssl s_client -showcerts -connect host:443 </dev/null | openssl x509 -outform PEM > ca.pem

Never disable verification

ssl_verify: false (or SSL_VERIFY=false) turns TLS certificate verification off entirely, leaving the connection exposed to man-in-the-middle attacks. Do not disable verification — always resolve certificate problems by trusting the CA bundle instead.

Supported LLM Providers

Providers are defined in conf/providers.yml and activated by adding credentials under agent.providers. Use the /model command to configure and switch providers interactively.

  • Provider credentials live under agent.providers.<name> in agent.yml
  • The active provider/model is stored in .datus/config.yml (written by /model)
  • Node-level model overrides can still reference entries in agent.models for custom endpoints

General-purpose providers

Provider Typical models Interface Type Auth
openai gpt-5.2, gpt-4.1, o3 openai API key
deepseek deepseek-v4-pro, deepseek-v4-flash deepseek API key
claude claude-sonnet-4-5, claude-opus-4-5 claude API key
kimi kimi-k3, kimi-k2.6 kimi API key
qwen qwen3-max, qwen3-coder-plus openai API key
gemini gemini-2.5-flash, gemini-2.5-pro gemini API key
minimax MiniMax-M2.7, MiniMax-M2.5 minimax API key
glm glm-5, glm-4.7 glm API key
openrouter anthropic/claude-sonnet-4, openai/gpt-4o openrouter API key

OpenRouter — one key, 300+ models

openrouter is a unified gateway: a single OPENROUTER_API_KEY routes to any vendor. Its model names use the vendor/slug form (e.g. google/gemini-2.5-pro). The /model picker fetches the full live catalog from OpenRouter and lets you type to filter it.

Special-auth providers

Provider Interface Type Auth Notes
claude_subscription claude Claude subscription token The wizard first tries to auto-detect a local subscription credential and otherwise prompts for sk-ant-oat01-...
codex codex OAuth Uses locally available Codex OAuth credentials and verifies connectivity

Coding Plan providers

These providers target coding/planning-oriented endpoints. Even though their names include coding, they are configured exactly like any other model entry and can be used as agent.target or referenced from node-level model fields.

Provider Default model Interface Type Notes
alibaba_coding qwen3-coder-plus claude DashScope Anthropic-compatible coding endpoint
bigmodel_coding glm-5.1 claude BigModel Anthropic-compatible coding endpoint
zai_coding glm-5.1 claude Z.AI Anthropic-compatible coding endpoint
minimax_coding MiniMax-M2.7 claude MiniMax Anthropic-compatible coding endpoint
kimi_coding kimi-for-coding claude Kimi coding endpoint

When to choose a coding plan provider

If your priority is general chat, SQL generation, or cost efficiency, start with a regular provider.

If you want a default model that is better aligned with planning, code generation, and structured task decomposition, or if you use Plan Mode frequently, add one of the *_coding providers and route specific nodes to it.

Environment variables and model overrides

All providers support environment-variable references in api_key, for example:

api_key: ${OPENAI_API_KEY}

For OpenAI, DeepSeek, Claude, Kimi, Qwen, Gemini, and OpenRouter, the configuration wizard can prompt with provider-specific environment variable hints (e.g. ${OPENROUTER_API_KEY}). For minimax, glm, and the *_coding providers, you can still enter values such as ${MINIMAX_API_KEY}, ${GLM_API_KEY}, ${KIMI_API_KEY}, or ${DASHSCOPE_API_KEY} directly.

The current implementation also auto-applies fixed parameter overrides for a few models:

  • kimi-k3, kimi-k2.6: temperature: 1.0, top_p: 0.95
  • qwen3-coder-plus: temperature: 1.0, top_p: 0.95

Provider Configuration Examples

With the new provider-level configuration, you only need to set credentials. All other fields (type, base_url, models list) are inherited from conf/providers.yml:

agent:
  providers:
    openai:
      api_key: ${OPENAI_API_KEY}
    deepseek:
      api_key: ${DEEPSEEK_API_KEY}
    claude:
      api_key: ${ANTHROPIC_API_KEY}
    gemini:
      api_key: ${GEMINI_API_KEY}
    kimi:
      api_key: ${KIMI_API_KEY}
    qwen:
      api_key: ${DASHSCOPE_API_KEY}
    openrouter:
      api_key: ${OPENROUTER_API_KEY}
agent:
  providers:
    claude_subscription:
      auth_type: subscription
      # Token is auto-detected or entered via /model
agent:
  providers:
    codex:
      auth_type: oauth
      # OAuth flow is handled via /model
agent:
  models:
    my-internal:
      type: openai
      base_url: https://internal.example.com/v1
      api_key: ${MY_KEY}
      model: internal-gpt-4

Legacy Format

The previous format with full type, base_url, api_key, and model under agent.models is still supported for backward compatibility. Existing configurations continue to work without changes.

Agentic Nodes

agent.agentic_nodes is where Datus configures chat and subagent behavior.

This section is used for:

  • built-in agentic nodes such as chat, explore, gen_sql, gen_visual_report, gen_dashboard, and scheduler
  • custom subagents created with the unified agent TUI (/agent or /subagent)
  • advanced manual aliases that point a custom name at a built-in node class

Common Fields

The runtime currently reads these commonly used fields from agentic_nodes entries:

  • model: provider key from agent.models (custom entries only; omit to inherit the active provider/model)
  • system_prompt: subagent name / prompt template base name
  • node_class: node implementation to use, such as gen_sql, gen_visual_report, explore, gen_table, gen_skill, gen_dashboard, or scheduler
  • prompt_version, prompt_language
  • agent_description
  • tools, mcp, skills
  • rules
  • max_turns
  • workspace_root
  • scoped_context
  • subagents
  • bi_platform for dashboard agents
  • scheduler_service for scheduler agents

Dosi is the built-in semantic engine and needs no engine selection. An old agent.services.semantic_layer entry is ignored with a warning.

scoped_kb_path is deprecated. New configs use shared global storage with query-time filters instead of per-subagent scoped KB directories.

subagents Delegation Control

subagents controls whether the node exposes the task() tool and which subagent types it may delegate to.

  • subagents: "*": allow all discoverable subagents except self
  • subagents: explore, gen_sql: allow only a named subset
  • blank or omitted:
  • chat defaults to *
  • most other agentic nodes default to explore
  • explicitly setting an empty value disables delegation

scoped_context

scoped_context limits what the subagent should see from shared metadata and knowledge:

scoped_context:
  datasource: finance
  tables: mart.finance_daily, mart.finance_budget
  metrics: finance.revenue.daily_revenue
  sqls: finance.revenue.region_rollup

When writing YAML manually, set datasource explicitly. The unified agent TUI's Custom-tab wizard fills it from the current database automatically.

Example

agent:
  agentic_nodes:
    chat:
      model: claude
      max_turns: 50
      subagents: "*"

    finance_report:
      node_class: gen_visual_report
      model: claude
      system_prompt: finance_report
      prompt_version: "1.0"
      prompt_language: en
      agent_description: "Finance reporting assistant"
      tools: semantic_tools.*, db_tools.*, context_search_tools.list_subject_tree
      subagents: explore, gen_sql
      max_turns: 30
      scoped_context:
        datasource: finance
        tables: mart.finance_daily
        metrics: finance.revenue.daily_revenue
        sqls: finance.revenue.region_rollup

    sales_dashboard:
      node_class: gen_dashboard
      model: claude
      bi_platform: superset
      max_turns: 30

    semantic_modeling:
      model: claude
      max_turns: 30

    etl_scheduler:
      node_class: scheduler
      model: claude
      scheduler_service: airflow_prod
      max_turns: 30

Context compaction (automatic minor/major passes that keep a long session within the model's context window) is configured under agent.compact. See Context Compaction for how it works and the tunable parameters.

SQL Read-Only Mode

Set agent.sql_read_only to enforce read-only SQL across CLI, API, MCP and workflow execution:

agent.yml
agent:
  sql_read_only: true  # default: false

This blocks SQL writes, DDL and cross-datasource result transfers regardless of the interactive permission profile. Statements that contain writes inside a CTE or EXPLAIN are also refused. The setting requires no plugin and cannot be disabled by a request once enabled for the deployment.

For interactive confirmation of individual tool calls, see direct tool execution.

Complete Configuration Example

Here's a comprehensive agent configuration example with the provider-level format:

agent.yml
agent:
  # Provider credentials (models and metadata from conf/providers.yml)
  providers:
    openai:
      api_key: ${OPENAI_API_KEY}
    deepseek:
      api_key: ${DEEPSEEK_API_KEY}
    claude:
      api_key: ${ANTHROPIC_API_KEY}
    gemini:
      api_key: ${GEMINI_API_KEY}
    claude_subscription:
      auth_type: subscription
    codex:
      auth_type: oauth

  # Custom models for self-hosted endpoints (optional)
  models:
    my-internal:
      type: openai
      base_url: https://internal.example.com/v1
      api_key: ${MY_KEY}
      model: internal-gpt-4

And the corresponding project-level override:

.datus/config.yml
target:
  provider: openai
  model: gpt-4.1
default_datasource: my_duckdb