Files
cleveragents-core/opencode.json
T
drew 80d61de942 feat(auto-agents): R3 wrapper-chain retirement — direct task-implementor variants
Eliminates the remaining LLM wrapper chain (``tier-dispatcher`` +
``tier-{min,0,1,2}`` selectors) between the Python dispatcher and the
``task-implementor`` worker. Follows the R2 implementation-worker
retirement (6e63073ad, 2026-05-16); both wrappers were pure routing
agents with no per-cycle judgment that could not be moved to Python.

Architecture
------------

Before (R2 baseline):
  dispatch_implementer.py
    → tier-dispatcher (LLM)
        → estimator-implementation (LLM, judgment)
        → tier-N selector (LLM, pure pass-through)
            → task-implementor (LLM, the actual work, via `task` hop)

After (R3):
  dispatch_implementer.py
    → estimator-implementation (LLM, judgment — invoked top-level)
    → task-implementor-tier-N (LLM, the actual work, NO `task` hops)

Two LLM hops eliminated per cycle. The ``task`` tool hop between the
tier-N selector and task-implementor is gone too, so the dispatcher's
prefetched ``## Pre-fetched …`` sections survive intact in the
worker's prompt — closing the structural cause of the ~30-80
per-session ``implementer_pr_context.py read --pr N`` round-trips
the worker burned to recover summarised-away context.

Cost savings (4-day measurement window, $-figures based on
local-claude pricing with caching):

- Eliminating tier-dispatcher sessions (32/day): ~$5-15/day
- Eliminating tier-N selector sessions (15/day): ~$2-5/day
- Eliminating prefetch round-trips (229/4d → expected near 0): ~$20-40/day

Aggregate at current traffic: roughly $30-60/day, $900-1,800/month.

What changed
------------

1. **New ``sync_tier_models.py`` scope** — generates per-tier
   ``task-implementor-{slot}.md`` + matching
   ``.opencode/models/task-implementor-{slot}.txt`` files from
   ``task-implementor.md`` (the byte source). Dropped: the bare
   ``tier-N.txt`` model files (no consumer) and the
   tier-dispatcher.md mapping-table generation (no file).

2. **New ``_call_python_estimator``** in dispatch_implementer.py
   invokes ``estimator-implementation`` as a top-level OpenCode
   session, parses ``{is_confident, recommended_tier}``, returns the
   tier integer or None. Includes a heartbeat-refresh on_poll so a
   30-180 s estimator call cannot trigger the launcher's hung-
   process watchdog. Estimator switched from ``mode: subagent`` to
   ``mode: all`` so the dispatcher can spawn it directly.

3. **New ``_resolve_task_implementor_for_tier(tier)`` helper** maps
   manifest tier integers to the matching ``task-implementor-{slot}``
   variant. Used by both the initial dispatch (in the prompt
   factory) and the in-cycle escalation respawn.

4. **WorkGroup contract extended** with
   ``requires_worker_agent_override: bool`` (default False, opt-in
   per group). The implementer's three WorkGroups set True;
   ``_resolve_effective_worker_agent`` raises a clear RuntimeError
   if the prompt_factory failed to populate the override (a code
   bug that would otherwise silently run every cycle at the static
   fallback tier).

5. **``_implementation_prompt_dispatch`` refactored** to:
   - Resolve the tier in Python (label-driven hint → estimator →
     default 0), honouring both the in-cycle escalation flag and the
     estimator-enabled flag.
   - Stash the resolved ``task-implementor-tier-<slot>`` agent name
     on the item context under
     ``WORKER_AGENT_OVERRIDE_ITEM_KEY`` (single source of truth in
     ``_dispatch_runtime``; imported into the higher layer).
   - Emit the worker body with ``escalation_tier: \`N\``` directly —
     no more ``escalation_tier_hint``, ``task_prompt:`` fence, or
     ``task_agent:``/``estimator_agent:`` outer parameters (all
     consumed by the retired tier-dispatcher).
   - Skip the estimator call on ``--dry-run`` so the operator-
     visible no-I/O contract holds.

6. **Retired agent files DELETED**:
   - ``.opencode/agents/tier-dispatcher.md``
   - ``.opencode/agents/tier-{min,0,1,2}.md``
   - ``.opencode/models/tier-{min,0,1,2}.txt``
   - Matching entries in ``opencode.json``'s agent block.

7. **Prose updates** to ``task-implementor.md`` (the byte-source for
   variants), ``estimator-implementation.md``, and production
   docstrings (``_block_store.py``, ``_pr_context_sentinel.py``,
   ``implementer_workspace.py``, ``_review_post.py``,
   ``_review_finalize.py``) reflecting the post-R3 chain. The
   filesystem handoff scripts (``implementer_pr_context.py``,
   ``implementer_workspace.py``) remain in place as the canonical
   read path — defensive against any future regression that re-
   introduces summarisation.

Tests
-----

2262 auto_agents passing (was 2268 pre-R3; net -6 from
removing tests pinning the retired wrapper-chain contract,
offset by +14 new tests pinning the post-R3 contract):

- ``TestEstimatorEnabledFlag`` rewritten to assert
  ``escalation_tier`` + agent-override semantics.
- New ``TestEstimatorPromptShape`` (5 tests) pins the body shape
  the Python estimator helper passes to the agent and the
  call shape into ``run_session_blocking``.
- New ``TestResolveEffectiveWorkerAgent`` (8 tests) directly
  covers the override priority chain — override present, empty,
  whitespace, non-string, whitespace-stripped, required-but-missing
  (loud fail), required-and-present.
- ``test_dry_run_never_calls_estimator`` pins the dry-run no-I/O
  contract via an exploding-stub guard on the estimator helper.
- ``TestDirectTierDispatch`` replaces the retired
  ``TestTierDispatcherShortCircuit`` suite in
  ``test_worker_permissions.py``.
- ``TestTaskImplementorVariantsAreByteIdentical`` ensures the
  four per-tier variants never hand-diverge from each other.
- ``test_no_legacy_tier_agents_in_opencode_agent_block`` fails
  loudly if any of the retired tier-* entries are re-introduced
  to ``opencode.json``.

Operator notes
--------------

- The C3 footgun (model swaps need OpenCode restart) still applies
  to the generated variants — edit ``tiers.yaml``, re-run
  ``python3 tools/sync_tier_models.py``, then restart OpenCode.
- The estimator now runs as a top-level OpenCode session; an
  operator grepping the session archive will see
  ``[AUTO-IMP-PR-N-estimator] estimator-implementation`` entries
  alongside the worker sessions.
- Roll-back: revert this commit + the R3 prep commit (b8c1e4903).
  Both wrappers + the static-fallback ``worker_agent`` come back;
  no schema migration needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 15:03:30 -04:00

421 lines
16 KiB
JSON

{
"$schema": "https://opencode.ai/config.json",
"permission": "allow",
"instructions": [
".opencode/instructions/*.md"
],
"mcp": {
"context7": {
"type": "local",
"command": [
"npx",
"-y",
"@upstash/context7-mcp"
],
"enabled": true
},
"sequential-thinking": {
"type": "local",
"command": [
"npx",
"@modelcontextprotocol/server-sequential-thinking"
],
"enabled": false
}
},
"provider": {
"anthropic": {
"models": {
"anthropic/claude-opus-4-6": {
"name": "Claude OPUS 4.6",
"limit": {
"context": 200000,
"output": 32768
}
},
"anthropic/claude-haiku-4-5": {
"name": "Claude Haiku 4.5",
"limit": {
"context": 200000,
"output": 32768
}
},
"anthropic/claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6",
"limit": {
"context": 200000,
"output": 32768
}
}
}
},
"local-claude": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "http://127.0.0.1:3456/v1",
"apiKey": "{env:LOCAL_ANTHROPIC_API_KEY}"
},
"models": {
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6 (local proxy)",
"limit": {
"context": 200000,
"output": 32768
},
"tools": true
},
"claude-opus-4-6": {
"name": "Claude Opus 4.6 (local proxy)",
"limit": {
"context": 1000000,
"output": 32768
},
"tools": true
},
"claude-haiku-4-5": {
"name": "Claude Haiku 4.5 (local proxy)",
"limit": {
"context": 200000,
"output": 32768
},
"tools": true
}
}
},
"CleverThis": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://ke5ntcikhnj2clcp.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-6-35B-A3B-GGUF-BF16": {
"name": "Qwen 3.6 35b A3B GGUF BF16 (Thinking)",
"tools": true
}
}
},
"CleverThis-2": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://bqdgwv2uzjgianhe.us-east-2.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"MiniMax-M2-7-GGUF-BF16": {
"name": "MiniMax M2.7 GGUF BF16 (Thinking)",
"limit": {
"context": 196608,
"output": 65536
},
"tools": true
}
}
},
"CleverThis-3": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://jve0bsgx6csdzln9.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Devstral-Small-2-24B-Instruct-GGUF": {
"name": "Devstral Small 2 24B GGUF (Instruct)",
"tools": true
}
}
},
"CleverThis-4": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://ntgtpdbn2vuag4yb.us-east-2.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Kimi-K2-6-GGUF-Q2-K-XL": {
"name": "Kimi K2.6 GGUF Q2_K_XL (Thinking)",
"tools": true
}
}
},
"CleverThis-5": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://fhe4kwehnm1rb275.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-Coder-Next-GGUF-BF16": {
"name": "Qwen3 Coder Next GGUF BF16",
"tools": true
}
}
},
"CleverThis-6": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://f0oelboag4bzw1zp.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Nemotron-3-Nano-30B-GGUF-Q8-K-XL": {
"name": "Nemotron 3 Nano 30B GGUF Q8_K_XL (Thinking)",
"tools": true
}
}
},
"CleverThis-7": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://dfwwzwtekzhnh4fl.us-east-2.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"DavidAU/Qwen3.6-40B-Claude-4.6-Opus-Deckard-Heretic-Uncensored-Thinking": {
"name": "Qwen 3.6 40B Uncensored BF16 (Thinking)",
"tools": true
}
}
},
"CleverThis-8": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://ki19d58snp1d3qa4.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-Coder-Next-GGUF-Q4-0": {
"name": "Qwen3 Coder Next GGUF Q4_0",
"tools": true
}
}
},
"CleverThis-9": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://m56026p5kxvout0d.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-6-35B-A3B-GGUF-MXFP4-MOE": {
"name": "Qwen 3.6 35b A3B GGUF MXFP4_MOE (Thinking)",
"tools": true
}
}
},
"CleverThis-10": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://dirv1cnem5wqzoax.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-235B-A22B-INST-GGUF-Q8-0": {
"name": "Qwen3 235b A22B GGUF Q8_0 (Instruct)",
"tools": true
}
}
},
"CleverThis-11": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://hueiyrdbly1ff4oo.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-235B-A22B-INST-GGUF-UD-Q2-K-XL": {
"name": "Qwen3 235b A22B GGUF UD-Q2_K_XL (Instruct)",
"tools": true
}
}
},
"CleverThis-12": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://atocunu78hjdnu3f.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-30B-A3B-INST-GGUF-UD-Q8-K-XL": {
"name": "Qwen3 30b A3B GGUF UD-Q8_K_XL (Instruct)",
"tools": true
}
}
},
"CleverThis-13": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://dpe3orf5en4581im.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-30B-A3B-INST-GGUF-UD-Q5-K-XL": {
"name": "Qwen3 30b A3B GGUF UD-Q5_K_XL (Instruct)",
"tools": true
}
}
},
"CleverThis-14": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://jamyigykfzm39bcu.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"MiniMax-M2-7-GGUF-UD-Q4-K-XL": {
"name": "MiniMax M2.7 GGUF UD-Q4_K_XL (Thinking)",
"tools": true
}
}
},
"CleverThis-15": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://n4u4h8h0fgintms4.us-east-1.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-6-35B-A3B-GGUF-UD-Q3-K-XL": {
"name": "Qwen 3.6 35b A3B GGUF UD-Q3_K_XL (Thinking)",
"tools": true
}
}
},
"CleverThis-16": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://kcgeda25msp4dkwm.us-east-2.aws.endpoints.huggingface.cloud/v1",
"apiKey": "{env:HF_TOKEN}",
"headers": {
"X-HF-Bill-To": "CleverThis",
"Authorization": "Bearer {env:HF_TOKEN}"
}
},
"models": {
"Qwen3-code-480B-A35B-INST-GGUF-1M-UD-Q3-K-XL": {
"name": "Qwen3 Code 480b A35B GGUF UD-Q3_K_XL (Instruct, 1M Context)",
"tools": true
}
}
},
"openai": {
"models": {
"gpt-5-codex": {
"name": "GPT-5 Codex"
},
"gpt-5-mini": {
"name": "GPT-5 Mini"
},
"gpt-5-nano": {
"name": "GPT-5 Nano"
},
"o4-mini": {
"name": "o4-mini"
}
}
},
"google": {
"models": {
"gemini-2.5-pro": {
"name": "Gemini 2.5 Pro"
}
}
}
},
"agent": {
"async-agent-util": { "model": "{file:./.opencode/models/default.txt}" },
"auto-agents": { "model": "{file:./.opencode/models/default.txt}" },
"conflict-resolver-worker": { "model": "{file:./.opencode/models/default.txt}" },
"estimator-implementation": { "model": "{file:./.opencode/models/default.txt}" },
"git-checkout-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-cleanup-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-clone-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-commit-and-push-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-commit-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-create-commit-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-fetch-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-force-push-with-lease-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-isolator-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-push-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-rebase-and-push-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-rebase-util": { "model": "{file:./.opencode/models/default.txt}" },
"git-stage-util": { "model": "{file:./.opencode/models/default.txt}" },
"implementation-worker": { "model": "{file:./.opencode/models/default.txt}" },
"pr-merge-supervisor": { "model": "{file:./.opencode/models/default.txt}" },
"pr-merge-worker": { "model": "{file:./.opencode/models/default.txt}" },
"pr-review-worker": { "model": "{file:./.opencode/models/default.txt}" },
"session-health-full-util": { "model": "{file:./.opencode/models/default.txt}" },
"session-health-quick-util": { "model": "{file:./.opencode/models/default.txt}" },
"session-health-util": { "model": "{file:./.opencode/models/default.txt}" },
"supervisor": { "model": "{file:./.opencode/models/default.txt}" },
"work-group-util": { "model": "{file:./.opencode/models/default.txt}" },
"task-implementor-tier-min": { "model": "{file:./.opencode/models/task-implementor-tier-min.txt}" },
"task-implementor-tier-0": { "model": "{file:./.opencode/models/task-implementor-tier-0.txt}" },
"task-implementor-tier-1": { "model": "{file:./.opencode/models/task-implementor-tier-1.txt}" },
"task-implementor-tier-2": { "model": "{file:./.opencode/models/task-implementor-tier-2.txt}" },
"ca-test-infra-improver": { "model": "{file:./.opencode/models/ca-test-infra-improver.txt}" }
}
}