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

Agent Format

The Duragent Format defines a portable, human-readable specification for AI agents. Agents are defined with YAML for structure and Markdown for prose — no code required.

Directory Layout

.duragent/agents/my-agent/
├── agent.yaml              # Agent definition (required)
├── SOUL.md                 # "Who the agent IS" (identity and personality)
├── SYSTEM_PROMPT.md        # "What the agent DOES" (core system prompt)
├── INSTRUCTIONS.md         # Additional runtime instructions (optional)
├── policy.yaml             # Tool policy (optional, version controlled)
├── policy.local.yaml       # User policy overrides (gitignored)
├── skills/                 # Skills directory (optional)
│   └── task-extraction/
│       └── SKILL.md
├── memory/                 # Agent's long-term memory
│   ├── MEMORY.md
│   └── daily/
└── tools/                  # CLI tools (optional)
    └── my-tool.sh

Agent Definition

Minimal Example

apiVersion: duragent/v1alpha1
kind: Agent
metadata:
  name: simple-assistant
spec:
  model:
    provider: openrouter
    name: anthropic/claude-sonnet-4
  system_prompt: ./SYSTEM_PROMPT.md

Full Example

apiVersion: duragent/v1alpha1
kind: Agent
metadata:
  name: productivity-assistant
  description: Personal productivity assistant with task management
  version: 1.0.0
  labels:
    domain: productivity

spec:
  model:
    provider: openrouter
    name: anthropic/claude-sonnet-4
    temperature: 0.7
    max_output_tokens: 4096

  soul: ./SOUL.md
  system_prompt: ./SYSTEM_PROMPT.md
  instructions: ./INSTRUCTIONS.md

  session:
    on_disconnect: continue
    max_tool_iterations: 10
    ttl_hours: 48
    compaction: archive
    context:
      max_history_tokens: 20000
      max_tool_result_tokens: 8000

  access:
    dm:
      policy: open
    groups:
      policy: allowlist
      allowlist: ["telegram:-100123456"]
      activation: mention

  memory:
    backend: filesystem

  tools:
    - type: builtin
      name: bash
    - type: cli
      name: git-helper
      command: ./tools/git-helper/script.sh
      description: Run git operations
      readme: ./tools/git-helper/README.md

  skills_dir: ./skills/

Fields Reference

metadata

FieldTypeRequiredDescription
namestringYesUnique identifier (alphanumeric + hyphens)
descriptionstringNoHuman-readable description
versionstringNoSemantic version
labelsmapNoKey-value labels for filtering

spec.model

FieldTypeRequiredDescription
providerstringYesopenrouter, openai, anthropic, or ollama
namestringYesModel name/identifier
temperaturefloatNoSampling temperature (0-2, default 0.7)
max_input_tokensintNoCap input tokens (for cost control)
max_output_tokensintNoMax response tokens
base_urlstringNoOverride provider’s base URL

Prompt Files

FieldPoints ToPurpose
soulMarkdown file“Who the agent IS” — identity and personality
system_promptMarkdown file“What the agent DOES” — core system prompt
instructionsMarkdown fileAdditional runtime instructions

SOUL.md example:

Communication style rules:
- Be concise and concrete; prefer bullet points over paragraphs
- Ask one clarifying question when requirements are ambiguous
- Match the user's tone; only use emojis if the user uses them first

spec.session

FieldTypeDefaultDescription
on_disconnectstringpausecontinue or pause
max_tool_iterationsint10Max tool call iterations per request
llm_timeout_secondsint300Timeout for LLM requests in seconds
ttl_hoursint(global)Per-agent session TTL override
compactionstring(global)Per-agent compaction override

spec.session.context

Controls how conversation history and tool results are truncated to fit within the model’s context window.

FieldTypeDefaultDescription
max_history_tokensint20000Max tokens for conversation history (0 = no cap)
max_tool_result_tokensint8000Max tokens per tool result
tool_result_truncationstringheadhead, tail, or both
tool_result_keep_firstint2First N tool results kept visible
tool_result_keep_lastint5Last M tool results kept visible

spec.tools

See Tools and Policies for full details.

spec.access

See Group Chat for full details.

spec.memory

See Memory for full details.

Versioning

The format uses API versions:

VersionStability
duragent/v1alpha1Alpha (current, breaking changes allowed)
duragent/v1beta1Beta (mostly stable)
duragent/v1Stable (future)

Examples

Q&A Bot

apiVersion: duragent/v1alpha1
kind: Agent
metadata:
  name: qa-bot
spec:
  model:
    provider: openrouter
    name: anthropic/claude-sonnet-4
  system_prompt: ./SYSTEM_PROMPT.md

Code Review Agent

apiVersion: duragent/v1alpha1
kind: Agent
metadata:
  name: code-reviewer
spec:
  model:
    provider: openrouter
    name: anthropic/claude-sonnet-4
    temperature: 0.3
  system_prompt: ./SYSTEM_PROMPT.md
  instructions: ./INSTRUCTIONS.md
  session:
    on_disconnect: pause
  tools:
    - type: builtin
      name: bash
    - type: cli
      name: git-diff
      command: ./tools/git-diff.sh
      description: Show git diff for review

Autonomous Supervisor

apiVersion: duragent/v1alpha1
kind: Agent
metadata:
  name: code-supervisor
spec:
  model:
    provider: anthropic
    name: claude-sonnet-4-20250514
  system_prompt: ./SYSTEM_PROMPT.md
  session:
    on_disconnect: continue
    max_tool_iterations: 50
  tools:
    - type: builtin
      name: bash