Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Duragent is configured via duragent.yaml (server-level) and agent.yaml (per-agent). This page covers server configuration; for agent configuration see Agent Format.

Environment Variable Interpolation

Configuration files support shell-style environment variable expansion:

SyntaxBehavior
${VAR}Required — errors if not set
${VAR:-default}Optional — uses default if not set
${VAR:-}Optional — empty string if not set

Environment Variables

Duragent reads certain environment variables directly at startup, independent of config file interpolation.

LLM Provider Keys

These are read directly from the environment — there is no YAML config equivalent. Anthropic also supports OAuth login via duragent login anthropic, which stores credentials at ~/.duragent/auth.json and takes precedence over the environment variable. See Authentication for details.

VariableRequiredDescription
ANTHROPIC_API_KEYNoAPI key for Anthropic (Claude). Not needed if using OAuth login.
OPENAI_API_KEYNoAPI key for OpenAI-compatible providers
OPENROUTER_API_KEYNoAPI key for OpenRouter

At least one LLM provider must be configured for agents to function.

Tool Keys

These are read directly from the environment — there is no YAML config equivalent.

VariableRequiredDescription
BRAVE_API_KEYNoBrave Search API key. Enables the web_search built-in tool.

Gateway Tokens

Gateway tokens are handled differently depending on how you run the gateway:

  • In-process (compiled-in feature): the token comes from the bot_token field in duragent.yaml, which supports ${VAR} interpolation.
  • Standalone binary: the token is read directly from the environment variable below.

These are separate code paths — they do not conflict.

VariableBinaryDescription
DISCORD_BOT_TOKENduragent-discordDiscord bot token
TELEGRAM_BOT_TOKENduragent-telegramTelegram bot token

Tip: When running gateways as external plugins (via gateways.external[]), you can forward these through the env field in duragent.yaml using ${VAR} interpolation instead of relying on the host environment.

duragent.yaml

Full Example

# Workspace root (default: .duragent)
# workspace: .duragent

# Server
server:
  host: 0.0.0.0
  port: 8080
  request_timeout_seconds: 300
  idle_timeout_seconds: 60
  keep_alive_interval_seconds: 15
  admin_token: ${ADMIN_TOKEN:-}
  api_token: ${API_TOKEN:-}

# Agent directory (optional, defaults to {workspace}/agents)
# agents_dir: .duragent/agents

# Services
services:
  session:
    # path: .duragent/sessions

# World memory
world_memory:
  # path: .duragent/memory/world

# Sessions
sessions:
  ttl_hours: 168
  compaction: discard

# Gateways
gateways:
  telegram:
    enabled: true
    bot_token: ${TELEGRAM_BOT_TOKEN}

  external:
    - name: discord
      command: /usr/local/bin/duragent-discord
      args: ["--verbose"]
      env:
        DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}
      restart: on_failure

# Routes
routes:
  - match:
      gateway: telegram
      sender_id: "123456789"
    agent: personal-assistant

  - match:
      gateway: telegram
      chat_type: group
    agent: group-moderator

  - match: {}
    agent: default-assistant

# Sandbox
sandbox:
  mode: trust

Fields Reference

Server

FieldTypeDefaultDescription
server.hoststring127.0.0.1Bind address
server.portu168080HTTP port
server.request_timeout_secondsu64300Non-streaming request timeout
server.idle_timeout_secondsu6460SSE idle timeout
server.keep_alive_interval_secondsu6415SSE keep-alive interval
server.admin_tokenstring?noneAdmin API token
server.api_tokenstring?noneAPI token. If set, API endpoints require this token. If not set, only localhost requests are accepted.
server.max_connectionsusize1024Maximum concurrent connections

Workspace

FieldTypeDefaultDescription
workspacepath?.duragentWorkspace root directory
agents_dirpath?{workspace}/agentsAgent definitions directory
services.session.pathpath?{workspace}/sessionsSession storage directory
world_memory.pathpath?{workspace}/memory/worldShared world memory directory

Sessions

FieldTypeDefaultDescription
sessions.ttl_hoursu64168Hours of inactivity before session expiry. 0 disables.
sessions.compactionenumdiscarddiscard, archive, or disabled

Gateways

FieldTypeDefaultDescription
gateways.telegram.enabledbooltrueEnable Telegram gateway (requires gateway-telegram feature)
gateways.telegram.bot_tokenstringrequiredTelegram bot token
gateways.discord.enabledbooltrueEnable Discord gateway (requires gateway-discord feature)
gateways.discord.bot_tokenstringrequiredDiscord bot token
gateways.external[].namestringrequiredGateway identifier
gateways.external[].commandstringrequiredPath to gateway binary
gateways.external[].argsarray[]Command arguments
gateways.external[].envmap{}Environment variables
gateways.external[].restartenumon_failurealways, on_failure, or never

Routes

FieldTypeDescription
routes[].matchobjectMatch conditions (all must match, AND logic)
routes[].agentstringAgent to route to

Match conditions:

FieldDescription
gatewayGateway name (telegram, discord)
chat_typedm, group, or channel
chat_idSpecific chat ID
sender_idSpecific user ID

Routes are evaluated top-to-bottom; first match wins. An empty match: {} acts as a catch-all.

Sandbox

FieldTypeDefaultDescription
sandbox.modestringtrusttrust (only supported mode; bubblewrap and docker are planned)

Path Resolution

All relative paths are resolved relative to the config file directory, not the current working directory. When optional path fields are omitted, they default to subdirectories of the workspace.

Context Window Management

Context window settings are configured per-agent in agent.yaml under spec.session.context. See Agent Format > session.context for details.

Duragent automatically detects context window sizes from model names when max_input_tokens is not set. Supported model families include Claude, GPT-4/5, Gemini, Grok, DeepSeek, Qwen, Llama, and Mistral.