Skip to content

feat: read .devswarm/config.toml for per-role backend/model routing#293

Closed
justrach wants to merge 2 commits intomainfrom
feat/config-toml-routing
Closed

feat: read .devswarm/config.toml for per-role backend/model routing#293
justrach wants to merge 2 commits intomainfrom
feat/config-toml-routing

Conversation

@justrach
Copy link
Copy Markdown
Owner

@justrach justrach commented Mar 6, 2026

Summary

  • Adds src/config.zig — minimal TOML parser for .devswarm/config.toml
  • Wires config into resolveWithProbe() so per-role and global provider settings take effect at runtime
  • Resolution chain now includes config overrides between MCP params and static role specs

What this enables

Users can now control which model/backend each agent role uses by editing .devswarm/config.toml:

[provider]
primary = "claude"
claude_default = "sonnet"  # global default when no role/grid override

[agents.reviewer]
model   = "opus"           # use Opus for review agents
backend = "codex"          # route reviewer to Codex backend
max_turns = 5

[agents.finder]
model = "haiku"            # use cheap Haiku for search agents

Resolution chain (highest → lowest priority)

  1. MCP param override (model: "opus" in tool call)
  2. config.toml [agents.<role>].model / .backend / .sandbox / .max_turns
  3. Static role spec (roles.zig built-in defaults)
  4. Grid tier (grid.zig role→model table)
  5. config.toml [provider].claude_default (global model default)
  6. Mode default (smart→Sonnet, deep→Opus, etc.)

Test plan

  • All 64 existing tests still pass
  • 4 new config.zig tests (parse, role overrides, comments, loadDefault)
  • 3 new resolve.zig tests (per-role model, primary backend, max_turns from config)
  • No memory leaks (GPA clean)

justrach and others added 2 commits March 6, 2026 11:14
Add src/config.zig — a minimal TOML parser that reads the config file
written by `devswarm init`. Wire it into resolveWithProbe() so that
per-role and global provider settings from config.toml take effect at
runtime without any MCP param changes.

Resolution chain (highest priority first):
  1. MCP param override (model: "opus" in tool call)
  2. config.toml [agents.<role>].model / .backend / .sandbox / .max_turns
  3. Static role spec (roles.zig built-in defaults)
  4. Grid tier (grid.zig role→model table)
  5. config.toml [provider].claude_default (global default model)
  6. Mode default (smart→Sonnet, deep→Opus, etc.)

Example .devswarm/config.toml that makes reviewer use Opus on Codex:
  [agents.reviewer]
  model   = "opus"
  backend = "codex"

All 64 existing tests pass + 4 new config tests + 3 new resolve tests.

Generated with AI

Co-Authored-By: AI <ai@example.com>
Adds src/notify.zig — a thread-safe notifications/message emitter that
writes JSON-RPC notifications to stdout while a long-running tool is
executing. MCP clients (Claude Code) display these inline during the
"Running…" wait, giving real-time feedback.

How it works:
  JSON-RPC is full-duplex. The server sends notifications (no `id` field)
  at any point while processing a `tools/call` request. The client shows
  them as status lines. The final result is correlated by the original id.

Changes:
- src/notify.zig: mutex-protected send(), supports Content-Length framing
- src/main.zig: call notify.init(g_use_headers) after framing detection
- src/swarm.zig: emit phase markers — "decomposing", "N agents running",
  "synthesizing" — so users see swarm progress instead of just "Running…"
- src/tools.zig: add optional `title` param to run_swarm; displayed in
  the phase notification so tool calls show a readable label rather than
  the full raw prompt blob

Generated with AI

Co-Authored-By: AI <ai@example.com>
@yxlyx
Copy link
Copy Markdown
Collaborator

yxlyx commented Mar 22, 2026

Superseded by #339 (rebased with conflict resolution)

@yxlyx yxlyx closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants