Repository navigation
feat: per-model code-mode capability flags with an "auto" master-switch tier - #114695
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 4:33 PM ET / 20:33 UTC. ClawSweeper reviewWhat this changesAdds Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep this PR open for maintainer product review and one more real-runtime proof pass. The implementation is a coherent additive opt-in path, and the existing Priority: P2 Review scores
Verification
How this fits togetherCode Mode changes the tool surface exposed to an agent run: normal tools are compacted behind flowchart LR
Config[Operator Code Mode setting] --> Gate[Per-model engagement gate]
Catalog[Provider model catalog metadata] --> Gate
Gate --> Embedded[Embedded agent tool surface]
Gate --> Harness[Provider harness tool surface]
Embedded --> Output[Code Mode or normal tools]
Harness --> Output
Output --> Request[Provider request]
Decision needed
Why: The patch is mechanically additive, but choosing which provider models receive a different model-facing tool surface is ongoing product and provider-policy ownership rather than a purely technical correction. Before merge
Agent review detailsSecurityNone. PR surfaceSource +123, Tests +158, Docs +91. Total +372 across 36 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this is a feature PR. The PR body supplies a credible embedded live-run path, but the full changed behavior still needs cross-surface runtime observation. Is this the best way to solve the issue? Unclear: the shared per-model gate and provider-owned metadata are a maintainable design, but maintainers must first accept the preferred-model policy and the runtime proof should cover both modified tool-surface paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3b008b061dcb. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
82ed838 to
efa47fd
Compare
|
Merged via squash.
|
…ch tier (openclaw#114695) * feat(tools): per-model code-mode capability flags and auto master-switch tier * feat(anthropic): flag claude-sonnet-4-6 as code-mode preferred * revert(anthropic): drop claude-sonnet-4-6 from the code-mode preferred set * test(anthropic): type the manifest compat field in the catalog contract test * fix(anthropic): carry catalog compat onto hand-built forward-compat model rows
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
tools.codeMode.enabledis all-or-nothing today:trueforces the compact code-mode surface onto every tool-capable run, including models that do not write short orchestration programs reliably, andfalseleaves the savings on the table for models that clearly benefit. Operators who mix strong hosted models with weaker or local ones have no way to say "use code mode where it wins, normal tools elsewhere".Why This Change Was Made
Adds a per-model capability flag to the model catalog compat surface (
compat.codeMode: "preferred" | "capable", absent = capable) and an additive"auto"tier on the master switch."auto"engages code mode only for catalog-preferred models, resolved at the two run engagement gates (embedded attempt prep and the harness tool-surface bridge) where the prepared model row is already in hand — no request-time catalog rediscovery.true/falsebehavior is byte-identical to before, the shipped default staysfalse, and the flag is provider-owned catalog metadata: values live in each provider plugin's manifest/catalog and core reads only the generic compat field. For OpenAI models the flag matters only when a run resolves to the OpenClaw embedded runtime; default OpenAI routing to the Codex-style harness surface is unchanged.Live verification surfaced one latent bug this PR also fixes: the Anthropic plugin's hand-built forward-compat model rows (used when the runtime prefers plugin-resolved modern models, including env-key-only runs with an empty model registry) silently dropped catalog
compatmetadata. The row now carries registry compat when present and falls back to a lazily indexed manifest compat lookup, with regression tests inextensions/anthropic/forward-compat-generation.test.ts.Codex boundary check for the touched stream wrapper (
createCodexNativeWebSearchWrapperinsrc/llm/providers/stream-wrappers/openai.ts): the sibling Codex source defines the provider-nativeweb_searchToolSpec payload entry incodex-rs/tools/src/tool_spec.rs(WebSearch variant,#[serde(rename = "web_search")]). This PR does not change that payload contract; it only adds an OpenClaw-side signal (openclawCodeModeToolSurfacestream option) so the provider-family wrapper skips native web-search injection consistently when an"auto"-engaged run owns the tool surface — the same skip thatenabled: truealready triggers via config.The
"auto"tier makes catalog annotations a runtime input for opted-in operators; the owner has accepted ownership of the initial preferred-model list and future catalog corrections as provider-owned policy. Flipping the default fromfalseto"auto"is a deliberate one-line owner follow-up, intentionally not part of this PR.User Impact
Operators can set
tools.codeMode: "auto"(orenabled: "auto") and get code-mode token savings (~30-50% total-token reduction at equal-or-better pass rates in A/B evals) on catalog-preferred models — the recent anthropic, gpt-5.5+, gemini-3.x, deepseek-v4, kimi-k3, MiniMax-M3, glm-5.1/5.2, and mimo-v2.5 lines — while unflagged and Ollama-served models keep normal tool exposure. Existingtrue/falseconfigs behave exactly as before, including the fail-closed promise when the QuickJS runtime is unavailable. The Labs toggle reads"auto"as on instead of silently narrowing it. Docs cover the new tier, the catalog flag semantics, the shipped preferred list, the OpenAI routing caveat, and tier-choice guidance.Evidence
Real behavior proof (isolated
OPENCLAW_STATE_DIR, dev CLIopenclaw agent --local, deliberately invalid provider keys so runs stop at the provider 401 after the tool surface is assembled; no credentials or private endpoints involved):tools.codeMode: "auto"+ catalog-preferred model (anthropic/claude-opus-5) — code mode engages:Side-by-side under one identical
tools.codeMode: "auto"config (Tool Search enabled as the positive control signal for the non-code-mode surface):tools.codeMode: true+ the same unflagged model — force-on still engages:Focused local runs (trusted source, linked-worktree wrapper):
node scripts/check-changed.mjs(delegated to Blacksmith Testbox): green, exit 0 (all lanes incl. formatting, ratchets, boundaries)node scripts/run-tsgo.mjscore/extensions/root test lanes andtsconfig.extensions.json: clean--mode uncommitted, run per commit): clean each round — "no accepted/actionable findings reported"node scripts/generate-docs-map.mjs --check— up to dateBranch drift: this PR intentionally does not chase moving
main; merge drift is advisory in this repo, GitHub blocks real conflicts, and the land flow validates hosted CI on the exact head.ClawSweeper rank-up notes: the preferred/unflagged comparison above is the requested after-fix side-by-side. A harness-path (plugin tool-bridge) runtime transcript is intentionally skipped: the only bundled consumer is the Copilot bridge, which requires live GitHub Copilot session auth; its gate is the same
isCodeModeEngagedForModelhelper proven above and is covered by the tool-surface-bridge unit table. The initial preferred-model policy and catalog-correction ownership are sponsored by the repository owner (this PR implements the owner-approved list, including the explicit decision to keepclaude-sonnet-4-6out of the preferred tier).