ワンクリックで
agent-context-budget
// Use when multi-agent work risks context overflow, memory growth, noisy logs, oversized handoffs, cross-session continuation, or parallel Codex and Gemini execution.
// Use when multi-agent work risks context overflow, memory growth, noisy logs, oversized handoffs, cross-session continuation, or parallel Codex and Gemini execution.
Use when the user asks to split a goal across Claude, Codex, or Gemini; plan a multi-agent run; break work into parallel agent tasks; or decompose a large task that needs bounded context handoffs. This is the **generic** multi-agent task splitter — writes `.coord/plan.yml` (a DAG) plus per-agent task files. NOT for research-domain routing that touches `.research/`, `.paper/`, or Zotero/Obsidian/NotebookLM ingest pipelines — for those, use `research-hub-multi-ai` instead (different artifact `.coord/multi_ai_plan.md`, research-hub-aware reconciliation).
Use when a multi-agent round needs a pre-merge gate, pre-commit check, verification before push, or a PASS/FAIL decision after reconciliation.
Use when multiple agents have completed a round and the user asks to reconcile outputs, compare Codex and Gemini, synthesize run results, identify conflicts, or decide what should be retried.
Use when a task needs single-agent self-correction across multiple iterations — write plan, execute, critique own output, revise plan, re-execute, until convergence or budget exhausted. Different from `agent-debate` (which is 2 agents arguing pro vs con); this is 1 agent looping over its own work.
Use when a consequential decision needs adversarial review, opposing agent arguments, a second opinion via debate, or explicit trade-off analysis before implementation.
Use when the user asks to update shared memory, initialize multi-agent memory, summarize decisions so far, identify open questions, or prepare a fresh session primer.
| name | agent-context-budget |
| description | Use when multi-agent work risks context overflow, memory growth, noisy logs, oversized handoffs, cross-session continuation, or parallel Codex and Gemini execution. |
Context governor for multi-agent rounds. The core rule is simple:
keep .coord/ as the canonical state, pass agents compact packets,
and never paste raw logs or unbounded memory into the main session.
Use this before or during:
.coord/memory.yml, .ai/*_log_*.txt, or agent
summaries are starting to dominate the prompt.Not for small one-agent edits. Use the direct delegate skill instead.
If .coord/plan.yml lacks context_policy, add this block:
context_policy:
main_session_token_budget: 3000
task_packet_token_budget: 6000
result_summary_word_budget: 250
memory_digest_token_budget: 1200
log_tail_lines_on_error: 50
raw_log_policy: path-only
agentmemory: optional
# W3 — $ cost gate per task (v0.2.2+)
# Optional. If set, agent-acceptance-gate flags any task whose
# codex/gemini delegate exceeded the cap. Estimated from token
# usage × provider price (Anthropic / OpenAI / Google rates).
# Set per-task in plan.yml tasks[].budget.max_cost_usd to override.
default_max_cost_usd: 0.50 # default $ ceiling per task
total_round_max_cost_usd: 5.00 # hard stop for the entire round
Why both token and cost budgets? Token gate prevents context
bloat (a session quality concern). Cost gate prevents runaway delegation
spend (a financial concern). They're orthogonal: a 2k-token delegate
call can cost $0.05 (Claude Haiku) or $0.50 (Claude Opus), so token
count alone doesn't bound dollars.
Per-task override example:
# in plan.yml
tasks:
- id: T1
agent: codex
slug: simple-refactor
budget:
max_cost_usd: 0.10 # this task is mechanical, cap low
- id: T2
agent: codex
slug: complex-rewrite
budget:
max_cost_usd: 2.00 # this task needs frontier model, allow higher
.coord/plan.yml and .coord/memory.yml if present..coord/context_<NNN>.md with:
agentmemory recall queries, if available.coord/session_primer.md with:
result.json status is error.agentmemory is a recall cache, not the source of truth.
.coord/session_primer.md..coord/memory.yml only..coord/plan.yml, result files, reconciliation, and tests.Promote only:
what and why.Do not promote:
End with:
[agent-context-budget]
Round: <N>
Policy: .coord/plan.yml context_policy
Context plan: .coord/context_<NNN>.md
Session primer: .coord/session_primer.md
Raw logs: path-only; failure tail max 50 lines
agentmemory: optional cache, not required
.ai/ paths. Inline critical context because
.ai/ may be gitignored..coord/
artifacts.When: ≥ 3 task packets exist and you want to verify they stayed
within the declared task_packet_token_budget (default 6000 tokens
≈ 24 KB) without re-reading them all in the main session.
Why: After writing .coord/context_<NNN>.md + session_primer.md,
the main session has the policy in context but doesn't need to re-read
every packet to verify compliance. A subagent can scan all packets
and return only the over-budget list.
Pattern:
Spawn `code-reviewer` subagent:
- Read .coord/context_<NNN>.md (the declared per-task budgets)
- Read each .ai/<agent>_task_<NNN>_*.md file referenced in plan.yml
- For each, count rough tokens (word count × 1.3 as approximation)
- Return: a single PASS/FAIL line + list of any task slugs > 120%
of declared budget + suggested compression target
Main session reads only the verdict.
If subagent reports FAIL, regenerate the over-budget packets with tighter prompts before invoking delegates.
Every agent boundary is a commit boundary (see global rule:
~/.claude/CLAUDE.md → "Commit Discipline for Multi-Agent Work").
Specific to this skill: writing .coord/context_<NNN>.md and
.coord/session_primer.md are session-setup artifacts — commit
them as a single round-prep commit so the budget policy used for
the round is auditable. Pattern:
git add .coord/context_<NNN>.md .coord/session_primer.md
git commit -m "context: round <N> budget plan + session primer"
The acceptance gate later verifies actual round consumption against this committed policy.