Skip to main content
KRAIT

Configuration

Configure LLM providers, memory backends, and security rules for your KRAIT agent.

The krait.exs Config File

All agent configuration lives in config/krait.exs. This file is evaluated at startup and defines how KRAIT connects to LLM providers, where it stores memory, and which security rules govern self-evolution.

# config/krait.exs
import Config

config :krait,
  llm: [
    provider: :anthropic,
    model: "claude-sonnet-4-20250514",
    api_key: System.get_env("ANTHROPIC_API_KEY"),
    max_tokens: 8192
  ],
  memory: [
    backend: :postgres,
    pool_size: 5,
    embedding_model: :local
  ],
  sandbox: [
    runtime: :docker,
    timeout_ms: 30_000,
    memory_limit_mb: 512
  ]

LLM Providers

KRAIT supports multiple LLM providers out of the box. Switch between them by changing the :provider key:

| Provider | Key | Models | |---------------|---------------|---------------------------------| | Anthropic | :anthropic | Claude Sonnet, Claude Haiku | | OpenAI | :openai | GPT-4o, GPT-4o-mini | | Local (Ollama)| :ollama | Any GGUF model via Ollama |

You can also configure fallback chains so the agent degrades gracefully if a provider is unavailable:

config :krait, :llm,
  provider: {:fallback, [:anthropic, :ollama]},
  retry_delay_ms: 1_000

Memory Backends

The memory backend controls how the agent persists learned context across evolution cycles. Supported backends are :postgres, :sqlite, and :ets (in-memory, development only).

config :krait, :memory,
  backend: :sqlite,
  path: "priv/memory.db"

Security Rules

KRAIT ships with seven built-in security rules (KRAIT-001 through KRAIT-007) that constrain what the agent can modify during self-evolution. You can extend or override these in config/rules.exs:

# config/rules.exs
[
  %Krait.Rule{
    id: "CUSTOM-001",
    severity: :critical,
    description: "Prohibit network calls in skill modules",
    match: {:module_attribute, :skill, true},
    deny: [:httpc, :hackney, Req]
  }
]

Rules are enforced by Narsil during the validation phase of every evolution. See Your First Evolution for details on how validation integrates into the merge flow.

Environment Variables

Sensitive values like API keys should always be set via environment variables rather than hardcoded in krait.exs. KRAIT reads from .env files automatically in development mode:

# .env
ANTHROPIC_API_KEY=sk-ant-...
DATABASE_URL=postgres://localhost/krait_dev

For production deployments, consult Getting Started for the recommended secrets management approach.