# `libra code` declarative multi-agent configuration (OC-Phase 5).
#
# Drop into the project root as `agents.toml` to enable the
# `planner → coder → reviewer` pipeline. The `[code.multi_agent]`
# block must opt the runtime into the new path; with `enabled = false`
# (the default) the loader still parses the file but the dispatcher
# stays in single-agent mode for byte-equivalent legacy behaviour.
#
# See `docs/improvement/opencode.md` OC-Phase 5 for the full schema.

[code.multi_agent]
enabled = true
max_subagent_depth = 1
max_concurrent_subagents = 1

[code.goal]
enabled = false
auto_continue_on_resume = "ask"
max_continuation_loops = 50
require_completion_evidence = true

# ----- Agents ---------------------------------------------------------------

# Drives the conversation, decomposes the task, and dispatches sub-agents
# for the actual implementation + review.
[code.agents.planner]
mode = "primary"
model = "anthropic/claude-3-5-sonnet-latest"
tools = ["read_file", "list_dir", "grep_files", "task"]
steps = 30

# Implementation agent — writes patches and runs the test suite.
# `permission` rejects free-form `shell` use but allows the `write`
# category so the agent can apply patches via the registered tool.
[code.agents.coder]
mode = "subagent"
model = "deepseek/deepseek-chat"
tools = ["read_file", "list_dir", "apply_patch", "run_command"]
permission = { write = "allow", shell = "ask" }
steps = 40

# Read-only reviewer — explicitly denies `write` and `shell` so a
# regression that re-uses the reviewer to apply edits trips the
# pairing validator before any side effect.
[code.agents.reviewer]
mode = "subagent"
model = "openai/gpt-4o-mini"
tools = ["read_file", "list_dir", "grep_files"]
permission = { write = "deny", shell = "deny" }
steps = 15

# ----- Compaction -----------------------------------------------------------

[code.compaction]
model = "deepseek/deepseek-chat"
tail_turns = 3
preserve_recent_tokens = 4000

# ----- Budget ---------------------------------------------------------------
#
# The session-wide cap is the operator's safety net; the per-agent caps
# bound any single agent's contribution. Warning thresholds always sit
# strictly below the hard caps so the operator gets a chance to react.

[code.budget]
max_session_cost_usd = 5.0
warn_session_cost_usd = 2.0
max_session_tokens = 1_000_000

[code.budget.goal]
warn_cost_usd = 2.0
max_cost_usd = 5.0
warn_wall_clock_minutes = 30
max_wall_clock_minutes = 120

[code.budget.per_agent.coder]
max_cost_usd = 2.0
max_steps = 40

[code.budget.per_agent.reviewer]
max_cost_usd = 0.5
max_steps = 15
