Skip to content
Edit this page View source of this page

Config

Pegg is configured with a single JSON file per machine plus a few project-local files. There is no YAML or TOML variant.

The VS Code extension uses this same config and stores only its editor-specific options in VS Code settings (pegg.*).

File locations

Scope Path Purpose
Global ~/.peggco/pegg.json Providers, server, permission, theme, storage drivers, MCP and LSP servers
Project <project>/.pegg/ Project data: todos/, subagents/, plans/, rules/
Project <project>/.mcp.json Project MCP servers
Project <project>/.lsp.json Project language servers
Global ~/.pegg/permissions.json Remembered tool approvals and rejections
Global ~/.pegg/schedules.json Recurring schedules. Run history lives in ~/.pegg/schedule_runs/
Global ~/.pegg/vfs/ Per-workspace read-hash snapshots backing read-before-edit
Global ~/.pegg/projects/<workspace-key>/ Fallback location for project data when the working directory cannot hold .pegg/

The global file is created with defaults on first run. A missing file is not an error — Pegg falls back to built-in defaults. An unparsable file is an error.

Project data normally lives in <project>/.pegg/ so it can be committed with the repository. When that directory cannot be created — a read-only mount, a sandboxed process, or a working directory such as / — Pegg keeps running and stores the same data in ~/.pegg/projects/<workspace-key>/ instead. The workspace key is derived from the absolute working directory with symlinks resolved, so the data stays separated per project and one project reached through different paths (on macOS /tmp and /private/tmp, or a symlinked checkout) maps to a single key. Pegg logs the relocation once at startup.

pegg files prints every resolved path and whether it exists.

Viewing the config

pegg config show

Prints the resolved configuration as pretty-printed JSON with every API key masked. There are no config get / config set subcommands — edit the file directly.

Reference

providers[]

Configured LLM providers. See Providers & Models.

Key Type Default Description
provider string — Name of a registered provider (for example "openai"). Wins over driver
driver string — Raw wire protocol: "openai", "claude", or "gemini". Requires base_url
api_key string — API key, stored in plaintext
base_url string — Override the endpoint. Required for raw drivers. Named providers use their built-in default unless they explicitly support an override; pegg-forever, claude, codex, and cline honor this field
timeout int 120 HTTP timeout in seconds for one-shot requests (model list sync, non-streaming calls). Streaming responses are never cut off by this — a model may reason for minutes before emitting the first token; stop a run with Esc
max_retries int — Reserved; currently not read by the runtime
headers object — Extra HTTP headers merged onto the driver defaults
system_first_only bool false Only allow the system prompt in the first message. Later system messages (reminders, compaction summaries) are folded into the neighbouring user or tool message. Needed for providers that reject a late system message
models array — Model catalogue of the provider. Declared models are merged with the models the provider reports; a declared model wins for its id

Either provider or driver must be set.

Declaring models

models declares the models of a provider together with their metadata. The entry uses the same shape as the config object of an OpenAI-compatible /models response, so a model declared here and a model discovered from a provider look identical:

{
  "providers": [
    {
      "provider": "my-gateway",
      "driver": "openai",
      "base_url": "https://gw.example.com/v1",
      "api_key": "sk-...",
      "models": [
        {
          "id": "gpt-4o",
          "name": "GPT-4o",
          "config": {
            "max_input_tokens": 128000,
            "max_output_tokens": 16384,
            "input_cost_per_token": 0.0000025,
            "output_cost_per_token": 0.00001,
            "modalities": { "input": ["text", "image"], "output": ["text"] },
            "tool_call": true,
            "structured_output": true,
            "temperature": true,
            "reasoning_options": [
              { "type": "effort", "values": ["low", "medium", "high"] }
            ]
          }
        }
      ]
    }
  ]
}

Rules:

  • Declared models are merged with the models the provider reports. A declared model replaces the reported model with the same id; declared models the provider does not know are added.
  • A declared model without a config keeps the metadata of the reported model (or the metadata from the shared price table).
  • When the provider has no reachable /models endpoint, the declared models are used on their own.
  • Prices are per token. 2.5 USD per 1M tokens is 0.0000025.
  • reasoning_options declares the reasoning effort levels the model accepts. Declaring them implies supports_reasoning; without them the provider default is used.
  • The metadata fields are listed under Model metadata.

logger

Key Type Default Description
driver string "sqlite" "sqlite" writes ~/.pegg/logs.db; "console" keeps an in-memory buffer printed to stdout
level string "info" Minimum level to record: debug, info, warn, or error. PEGG_DEBUG=1 forces debug; PEGG_LOG_LEVEL overrides this value
max_log_count int 1000 Maximum retained log records

cache

Key Type Default Description
driver string "sqlite" "sqlite" uses ~/.pegg/cache.db; "json" uses ~/.pegg/cache.json

session

Key Type Default Description
driver string "sqlite" "sqlite" uses ~/.pegg/sessions.db; "json" stores one file per session under ~/.pegg/sessions/

changejournal

Per-message file tracking. The journal records every file the agent adds, modifies, or deletes so that reverting a chat message also restores the workspace, and undoing the revert re-applies the changes. Files edited by the user after the agent are never overwritten. Backups live under ~/.pegg/changejournal/<workspace-hash>/.

Key Type Default Description
enabled bool true Track file mutations and roll them back on revert
max_file_size int 1048576 Largest file, in bytes, that is backed up; larger files are reported as not tracked
budget int 67108864 Total backup budget, in bytes, per session
retention_days int 30 Journal data older than this is pruned on startup
"changejournal": {
  "enabled": true,
  "max_file_size": 1048576,
  "budget": 67108864,
  "retention_days": 30
}

notification

Desktop notifications while the app is in the background. See Notifications.

Key Type Default Description
drivers string[] ["os"] Drivers that receive every notification. "os" sends desktop notifications via the system notification service
enabled bool true Master toggle. When false, no notification driver is created

server

Used by pegg serve. See HTTP and ACP.

Key Type Default Description
host string "127.0.0.1" Bind address
port int 8080 Listen port
required_headers object — Required request headers for auth. Values are compared in constant time; Authorization schemes are case-insensitive, all other values must match exactly. An empty value only checks presence
headers object — Extra headers added to every HTTP API response. Vary and Access-Control-* are reserved for CORS and ignored here
cors_origins string[] [] Browser origins allowed to read API responses. Entries are trimmed of whitespace and trailing slashes and matched exactly. Empty disables CORS. Use ["*"] to opt in to wildcard CORS

theme

Key Type Default Description
theme string "dark" TUI theme name. Changed at runtime with Ctrl+T and saved back to this file

See TUI themes for the list.

permission

Controls when tools may run. See Permissions.

Key Type Default Description
default string "semi-ask" Mode when no rule matches: allow, semi-ask, ask, semi-judge, judge
rules object — Per-tool mode overrides, for example {"bash": "ask", "write": "allow"}
judge_provider string — Provider used by the judge. Decision-capable providers (openrouter, pegg-forever) use a decision model; other providers use the judge LLM. Unset → a decision model is used automatically when any decision-capable provider has an API key
judge_model string — Model used by the judge. For decision providers, the decision model ID (for example typesafe/jev-1.14); otherwise the judge LLM model
judge_threshold number 0.6 Minimum yes-probability for the decision judge to allow a call

compaction

Controls how Pegg manages context window pressure. Configurable from the TUI in Settings → Session → Compaction.

Key Type Default Description
enabled bool true Master toggle for compaction
strategy string[] ["tool-clearing", "sliding-window"] Ordered list of strategies to try. Options: tool-clearing, sliding-window, summarization
threshold float 80 Percentage of the model's context window that triggers compaction
max_messages int 50 Maximum recent messages to keep in sliding-window mode
max_tool_output_chars int 4000 Character limit for tool outputs; longer outputs are truncated
summarizer_provider string — Provider for the summarization strategy. Falls back to the agent's provider
summarizer_model string — Model for the summarization strategy. Falls back to the agent's model

Strategies:

  • tool-clearing — truncates individual tool output messages exceeding max_tool_output_chars. Applied passively on every LLM call.
  • sliding-window — when the threshold is reached, keeps only the most recent N messages (calculated from token budget, falling back to max_messages).
  • summarization — when the threshold is reached, uses a dedicated LLM agent to compress the conversation history into a summary. If the summary call fails, the history is left untouched and compaction retries on the next call instead of staying disabled.

Note

The threshold is a percentage of the model's input window. Declare a model's real window with providers[].models[].config.max_input_tokens; when a model declares none, Pegg assumes 128000 so compaction still triggers instead of being silently skipped.

Persistence: When a compaction runs, Pegg does not overwrite the original conversation. Instead, the compacted messages are stored in a new session linked to the previous one (a linked-list chain of sessions). The original session keeps its full history; the newest session in the chain holds the compacted messages and everything that follows. Loading a session always opens the newest session in its chain first — the compacted view — and scrolling up walks back through earlier (pre-compaction) conversations. When a session is resumed, compaction thresholds are re-checked against the loaded history, so sliding-window and tool-clearing also apply to resumed sessions.

stall

Recovers from provider requests that go silent — no error, no response, no stream chunks. When no chunk arrives for timeout_secs, Pegg cancels the attempt and re-issues the exact same request at the same point in the run loop. A successful retry is silent: no error, warning, or duplicate output is shown.

Key Type Default Description
enabled bool true Master toggle for stall detection
timeout_secs int 10 Idle window in seconds before the request is retried
max_retries int 0 Retries after the first attempt. 0 means unlimited, matching the retry middleware

Note

The idle window is measured between stream chunks. A reasoning model that pauses longer than timeout_secs between chunks will be treated as stalled; raise the value if you use such a model. Once any content, reasoning, or tool call has been delivered, Pegg does not retry — it returns an error instead of duplicating partial output.

smart_router

Selects the best model per agent and task instead of using one model for everything. When enabled, a decision model (JEV by default) picks a model from your configured providers for the orchestrator and each subagent. Pick Smart Router in the TUI at Settings → General → Model (listed above the regular models when enabled), or pass --model smart-router on the CLI for a single run.

Key Type Default Description
enabled bool false Master toggle. When on, the orchestrator and every subagent are routed
provider string — Decision provider used for routing (openrouter or pegg-forever). Unset → any decision-capable provider with an API key
model string — Decision model used for routing (default typesafe/jev-1.14)
agents object — Per-agent model preferences, keyed by agent name (orchestrator, explorer, developer, ...)

Each agent entry accepts:

Key Type Description
default string[] Preferred model IDs for this agent. Matching models are offered first, in order
difficulty object Per-task-difficulty lists keyed by trivial, moderate, complex. When configured, the decision model scores the task's difficulty first and the matching bucket's models are offered first
images string[] Preferred model IDs when the task has image attachments (e.g. a vision variant)

Routing behavior:

  • Routing is a system hook (OnModelResolve) registered by the router and applied by every agent at run start, before the provider check — so it works uniformly in the CLI, TUI, HTTP/ACP servers, and the SDK without per-entry-point code. The routed model is what appears in sessions and usage records.
  • The candidate list is built from every configured provider that has an API key. Per-agent preferences are offered first (by ID or display name), then all remaining models. Preference resolution: images when the task has attachments, else the difficulty bucket, else default.
  • When the run has image attachments, models without image input support are dropped from the list (even beyond the images preference).
  • The decision model's pick is always accepted — there is no confidence threshold.
  • Resolution order: difficulty score question (when difficulty is configured for the agent) → decision model choice question → LLM selection (using the preferred model) → the preferred model itself.
  • The orchestrator is routed when its run model is Smart Router (picked in the TUI model list or --model smart-router); subagents are always routed when the router is enabled.

With Team AI, pegg team sets provider to the team provider (pegg-team <team>) and model to the team's decision model. The team gateway serves the decision model through the normal chat path, so the router falls back to the LLM selection path when no separate decision provider is available.

agent_defaults

Per-agent default and fallback models written by pegg team or the recommended defaults applied after pegg login-pegg. They are applied to the orchestrator at TUI startup and to subagents at spawn unless the smart router manages that agent.

Key Type Description
<agent> object orchestrator, developer or explorer
.provider string Provider name, normally pegg-forever or pegg-team <team>
.model string Default model key
.fallback_provider string Fallback provider name
.fallback_model string Fallback model key
{
  "agent_defaults": {
    "orchestrator": {
      "provider": "pegg-team Acme",
      "model": "gpt-4.1",
      "fallback_provider": "pegg-team Acme",
      "fallback_model": "gpt-4.1-mini"
    }
  }
}

stt

Speech-to-text settings. pegg team writes the team's default STT provider, models and selection here. See Speech-to-text providers for the built-in catalogue.

Key Type Default Description
providers array — Per-provider credentials and model catalogue. See stt.providers[]
provider string — Selected STT provider (pegg-team <team> for Team AI)
model string — Selected STT model key
streaming_model string — Optional streaming model written by Team AI defaults; the current CLI uses model for batch transcription
record_command string — Custom recording command
max_duration_secs int 120 Maximum recording length

The legacy top-level api_key, base_url, and stream_url are still accepted as fallbacks for the selected provider, but new configurations should place them inside the matching providers entry.

stt.providers[]

Key Type Default Description
provider string — Provider name. Either a registered STT provider (for example "openai") or a custom name
driver string — Raw STT wire protocol: "openai" or "assemblyai". Used when provider is not a registered provider. "openai" requires base_url
api_key string — API key, stored in plaintext
base_url string — Override the endpoint
stream_url string — Override the streaming WebSocket endpoint (AssemblyAI)
models array — Model catalogue for this provider. When non-empty it replaces the built-in catalogue

stt.providers[].models[]

Key Type Description
id string Model ID sent to the provider
name string Display name shown in the TUI and settings
streaming bool Marks the model as usable for realtime streaming (the provider must also support streaming)

Declaring STT models

Declared STT models have a smaller shape than LLM models — there is no metadata or config object. When models is omitted or empty, Pegg uses the built-in model list for that provider. When it is non-empty, it replaces the built-in list for that provider (unlike LLM models, STT models are not merged).

{
  "stt": {
    "provider": "pegg-team Acme",
    "model": "whisper-large-v3",
    "providers": [
      {
        "provider": "pegg-team Acme",
        "driver": "openai",
        "base_url": "https://team.example.com/v1",
        "api_key": "vsk_live_...",
        "models": [
          { "id": "whisper-large-v3", "name": "Whisper Large v3" },
          { "id": "gpt-4o-transcribe", "name": "GPT-4o Transcribe" }
        ]
      }
    ],
    "max_duration_secs": 120
  }
}

The selected model must exist in the provider's configured or built-in model list. A model marked "streaming": true is offered for realtime streaming; otherwise it is used for batch transcription only.

memory

Persistent, markdown-based memory for coding agents. A background observer distills each run's tool uses into observations, a librarian curates them into markdown files, and a memory panel is injected into future runs. See Memory for the full guide.

Key Type Default Description
enabled bool true Master switch for capture, storage, and panel injection
provider string — Legacy observer provider. Prefer observer.provider
model string — Legacy observer model. Prefer observer.model
observer object — { "provider": "...", "model": "..." } for the observer/summarizer/librarian LLM calls. Unset → the running agent's model
relevance object — { "provider": "...", "model": "..." } for decision-model relevance gating. Unset → the preferred decision provider
gate string "auto" Relevance gate for mem-search: auto, decision, llm, score, or off
threshold number 0.6 Minimum decision-model relevance for decision gating
context_budget int 8000 Max chars of the injected memory panel
max_results int 5 Default result count for mem-search
consolidate bool true Run the librarian to keep the curated memory files up to date
skip_tools string[] — Additional tools whose results are never captured

scheduler

Recurring background schedules. A lightweight scheduler starts with every long-running process (TUI, serve, connect) and runs each schedule as a separate child process, saving every run as a session. See Scheduling.

Key Type Default Description
enabled bool true Start the background scheduler with the app
store_dir string ~/.pegg Directory holding schedules.json and schedule_runs/
history_limit int 50 Maximum run records kept per schedule

hooks

Plugin hook bus. Controls whether plugins receive filter/action hooks and how long each hook may run. See Hooks for the full catalog.

Key Type Default Description
enabled bool true Master switch for all plugin hooks
disabled string[] [] Hook names to skip, for example llm.stream.chunk
timeout_seconds int 5 Default per-hook budget, clamped to 1–60
"hooks": {
  "enabled": true,
  "disabled": ["llm.stream.chunk", "tui.key"],
  "timeout_seconds": 5
}

mcp_servers

Map of server name to MCP server config.

Key Type Description
type string Transport: stdio, sse, or streamable-http. Inferred from url/command when omitted
command string Executable to spawn (stdio transport)
args string[] Command arguments
env object Extra environment variables (merged over the inherited environment)
url string Remote endpoint for SSE or Streamable HTTP
headers object HTTP headers for SSE and Streamable HTTP requests

language_servers

Map of server name to language server config.

Key Type Description
command string Language server executable
args string[] Command arguments
env object Extra environment variables
filetypes string[] File extensions this server handles
rootMarkers string[] Files used to detect the project root
download string Static binary URL to download when the command is not found
install string Shell command to install the server when the command is not found
version string Informational version
enabled bool false removes a server inherited from a lower-priority layer

Complete example

{
  "providers": [
    { "provider": "openai", "api_key": "sk-..." },
    {
      "provider": "openrouter",
      "api_key": "sk-or-..."
    },
    {
      "provider": "groq",
      "api_key": "gsk_...",
      "timeout": 60,
      "headers": { "X-Custom": "value" }
    },
    {
      "driver": "openai",
      "base_url": "http://localhost:11434/v1",
      "api_key": "ollama"
    }
  ],
  "logger": { "driver": "sqlite", "level": "info", "max_log_count": 1000 },
  "cache": { "driver": "sqlite" },
  "session": { "driver": "sqlite" },
  "server": {
    "host": "127.0.0.1",
    "port": 8080,
    "required_headers": { "Authorization": "Bearer secret" },
    "headers": { "X-Served-By": "pegg" },
    "cors_origins": ["http://localhost:5173"]
  },
  "theme": "dark",
  "permission": {
    "default": "semi-ask",
    "judge_provider": "pegg-forever",
    "judge_model": "typesafe/jev-1.14",
    "judge_threshold": 0.8,
    "rules": { "bash": "ask", "write": "allow" }
  },
  "compaction": {
    "enabled": true,
    "strategy": ["tool-clearing", "sliding-window"],
    "threshold": 80,
    "max_messages": 50,
    "max_tool_output_chars": 4000
  },
  "smart_router": {
    "enabled": true,
    "agents": {
      "orchestrator": {
        "default": ["deepseek-v4-flash"],
        "difficulty": {
          "trivial": ["deepseek-v4-flash"],
          "moderate": ["deepseek-v4-flash"],
          "complex": ["deepseek-v3", "deepseek-r1"]
        },
        "images": ["deepseek-v4-flash-vision-exp"]
      },
      "developer": {
        "default": ["qwen2.5-coder-7b"],
        "difficulty": {
          "complex": ["deepseek-v3", "claude-sonnet"]
        },
        "images": ["claude-sonnet"]
      }
    }
  },
  "memory": {
    "enabled": true,
    "gate": "decision",
    "threshold": 0.6,
    "context_budget": 8000,
    "max_results": 5,
    "consolidate": true,
    "observer": { "provider": "pegg-forever", "model": "deepseek-v4-flash" },
    "relevance": { "provider": "pegg-forever", "model": "typesafe/jev-1.14" }
  },
  "scheduler": {
    "enabled": true,
    "history_limit": 50
  },
  "hooks": {
    "enabled": true,
    "disabled": ["llm.stream.chunk"],
    "timeout_seconds": 5
  },
  "changejournal": {
    "enabled": true,
    "max_file_size": 1048576,
    "budget": 67108864,
    "retention_days": 30
  },
  "mcp_servers": {
    "db": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DEBUG": "true" }
    },
    "remote": {
      "type": "streamable-http",
      "url": "https://example.com/mcp",
      "headers": { "Authorization": "Bearer token" }
    }
  },
  "language_servers": {
    "gopls": {
      "command": "gopls",
      "filetypes": ["go"],
      "rootMarkers": ["go.mod"]
    }
  }
}

Project-local configuration

Only MCP and LSP servers support project-level files. Other settings are global.

.mcp.json
{
  "mcpServers": {
    "db": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres"] }
  }
}
.lsp.json
{
  "languageServers": {
    "gopls": { "command": "gopls", "filetypes": ["go"], "rootMarkers": ["go.mod"] }
  }
}

Project entries override global entries with the same name. Setting "enabled": false on a project LSP entry removes an inherited server.

Environment variables

Pegg does not read API keys or config paths from environment variables. The only variable that affects behavior is HOME (via the OS home directory), which determines where ~/.pegg/ lives. Spawned MCP and LSP subprocesses inherit the parent process environment plus any env entries you configure.