Skip to content

feat(agents): default code mode to per-model auto activation - #114906

Merged
steipete merged 1 commit into
mainfrom
feat/code-mode-auto-default-af7b
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
feat/code-mode-auto-default-af7b

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

PR #114695 added the "auto" tier for tools.codeMode.enabled (per-model activation gated on catalog compat.codeMode: "preferred" flags) but left the shipped default at false, so nobody gets code mode without hand-editing config. The Labs switch also wrote enabled: true, which force-engages code mode for every tool-capable run — including models never evaluated for it.

Why This Change Was Made

Owner product decision: "auto" is safe by construction — it engages code mode only for models the catalog explicitly flags as evaluated strong code-mode performers, while every unevaluated model keeps normal tool exposure. That makes it the right shipped default, and it makes true (global force-on) the wrong thing for a one-click Labs switch to write.

Two coupled changes:

  1. Resolver default flips from false to "auto" (src/agents/code-mode-runtime.ts readEnabled). Omitted config and tools.codeMode objects without enabled now resolve to "auto". Explicit false/true behave exactly as before. Schema help, exported type docs, and both docs pages updated to match; the zod schema is untouched (additive only — true stays valid everywhere).
  2. Labs Code Mode switch becomes Auto/Off (ui/src/pages/labs/labs-registry.ts). The on position writes enabled: "auto", never true; off writes enabled: false. A registry readEnabled mirrors the runtime resolver so the unset shipped default reads as on, and an existing enabled: true (config-only power-user state) still displays as on. The row description now states what Auto means in one line.

User Impact

This intentionally changes default behavior: code mode now engages by default for catalog-preferred models (the shipped list in docs/tools/code-mode.md). Set tools.codeMode.enabled: false (or flip the Labs switch off) to opt out. Models without the "preferred" catalog flag — including all local/Ollama models — are unaffected and keep normal tool exposure. No config migration needed; every previously valid value keeps its meaning, so there is no doctor migration and no compat shim.

Evidence

Real omitted-config behavior proof (actual resolveCodeModeConfig + createAgentHarnessToolSurfaceRuntime from this head, fed real bundled catalog entries — extensions/anthropic/openclaw.plugin.json claude-sonnet-5 (compat.codeMode: "preferred") and extensions/ollama/openclaw.plugin.json kimi-k2.5 (no flag) — with tools.codeMode entirely omitted from config):

resolveCodeModeConfig({}).enabled = "auto"
engaged(preferred anthropic/claude-sonnet-5) = true
engaged(unflagged ollama/kimi-k2.5)   = false
anthropic/claude-sonnet-5 (preferred): codeModeControlsEnabled=true model-visible tools=["exec","wait"]
ollama/kimi-k2.5 (unflagged): codeModeControlsEnabled=false model-visible tools=["read","web_search","sessions_list"]

The preferred model's model-visible surface collapses to exec/wait; the unflagged model's tool list is byte-identical to before this change.

  • node scripts/run-vitest.mjs src/agents/code-mode-runtime.test.ts src/agents/code-mode.test.ts ui/src/pages/labs/labs-page.test.ts — green (resolver default now "auto" for omitted/object-without-enabled; labs switch writes "auto"/false, never true; true, "auto", and unset all read as on; explicit false reads off).
  • node scripts/run-vitest.mjs src/agents/harness/tool-surface-bridge.test.ts src/config/schema.test.ts src/gateway/session-companion.test.ts src/agents/code-mode-swarm.test.ts src/agents/code-mode-headless.test.ts src/config/doc-baseline.test.ts src/config/zod-schema.agent-defaults.test.ts — green (auto/preferred engagement matrix, companion sessions still force code mode off, schema/doc baselines aligned).
  • pnpm ui:i18n:baseline run; no baseline drift beyond the English source change.

@steipete
steipete marked this pull request as ready for review July 28, 2026 03:46
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete
steipete force-pushed the feat/code-mode-auto-default-af7b branch from a710e65 to 1af3683 Compare July 28, 2026 03:47
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 12:56 AM ET / 04:56 UTC.

ClawSweeper review

What this changes

The branch changes omitted tools.codeMode.enabled configuration to default to per-model "auto" activation and changes the Labs Code Mode toggle to write "auto" or false instead of global force-on.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer landing review. It is a focused, owner-confirmed default-policy follow-up to the merged per-model Auto tier, and the updated body now supplies relevant after-fix runtime evidence for both preferred and unflagged catalog models; the remaining concern is the intentional upgrade behavior, not a demonstrated patch defect.

Priority: P2
Reviewed head: b3ae33f03a25e8fb3d9bd632e4fb0469464d9485

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, documented default-policy follow-up with relevant real runtime proof and no concrete patch defect identified; its remaining decision is the explicitly acknowledged compatibility tradeoff.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.
Evidence reviewed 5 items Runtime default change: The branch changes the resolver fallback for absent or unrecognized tools.codeMode.enabled values from false to "auto"; explicit boolean and "auto" values retain their existing meanings.
Upgrade control and UI alignment: The Labs control writes "auto" when enabled and false when disabled, while its reader treats only explicit false as off; accompanying tests cover unset, shorthand, object, true, auto, and false states.
Real behavior proof: The PR body and follow-up comment show after-fix terminal output from the actual resolver and harness tool-surface runtime with omitted configuration: a catalog-preferred Anthropic model engages Code Mode, while an unflagged Ollama model retains its normal tool surface.
Findings None None.
Security None None.

How this fits together

Code Mode determines whether an agent run exposes a compact exec/wait tool surface or its normal tools. Runtime configuration and provider-catalog compatibility metadata feed that decision, while the Labs UI writes the corresponding persisted configuration choice.

flowchart LR
  A[OpenClaw configuration] --> C[Code Mode resolver]
  B[Provider model catalog] --> D[Model eligibility]
  C --> E[Activation decision]
  D --> E
  E --> F[Agent or harness tool surface]
  G[Labs Auto Off toggle] --> A
Loading

Before merge

  • Resolve merge risk (P1) - Upgrading with Code Mode omitted will newly engage the compact, fail-closed Code Mode surface for every catalog-preferred model; users whose QuickJS-WASI runtime is unavailable will need the documented explicit false opt-out rather than silently receiving normal tools.
  • Resolve merge risk (P1) - The preferred-model catalog list now controls which existing installations change behavior, so future catalog corrections remain compatibility-sensitive provider policy.
Agent review details

Security

None.

PR surface

Source +14, Tests +43, Docs +1. Total +58 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 22 8 +14
Tests 3 48 5 +43
Docs 3 41 40 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 111 53 +58

Review metrics

Metric Value Why it matters
Code Mode default 1 default changed: false to "auto" Omitted configuration now changes the runtime tool surface for catalog-preferred models on upgrade.

Merge-risk options

Maintainer options:

  1. Land the documented Auto default (recommended)
    Accept the intentional upgrade behavior after required checks complete, with tools.codeMode.enabled: false remaining the explicit opt-out for all models.
  2. Keep Auto opt-in for now
    Pause this PR if maintainers no longer want catalog-preferred existing installations to enter the fail-closed Code Mode path by default.

Technical review

Best possible solution:

Land the explicit Auto/Off default only with the documented opt-out preserved and exact-head checks completed, keeping the existing catalog-preferred gate as the single source of activation policy.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is an intentional default-policy change, not a report of broken established behavior. The PR provides a high-confidence after-fix runtime comparison for omitted configuration across preferred and unflagged models.

Is this the best way to solve the issue?

Yes. Reusing the already-merged "auto" eligibility mechanism and making the Labs control write that existing tier avoids a competing default, a new configuration key, or force-enabling unevaluated models.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 42fdb81d97b6.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is an intentional, bounded default-policy change affecting agent tool exposure rather than an emergency regression.
  • merge-risk: 🚨 compatibility: Existing installations with omitted Code Mode configuration will receive automatic activation for catalog-preferred models after upgrade.
  • merge-risk: 🚨 availability: The newly default-engaged Code Mode path is documented to fail closed when its QuickJS-WASI runtime is unavailable.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body and follow-up provide after-fix terminal output from the actual resolver and harness tool-surface runtime using real bundled preferred and unflagged catalog entries; redact any private details if this evidence is expanded later.

Evidence

What I checked:

  • Runtime default change: The branch changes the resolver fallback for absent or unrecognized tools.codeMode.enabled values from false to "auto"; explicit boolean and "auto" values retain their existing meanings. (src/agents/code-mode-runtime.ts:153, b3ae33f03a25)
  • Upgrade control and UI alignment: The Labs control writes "auto" when enabled and false when disabled, while its reader treats only explicit false as off; accompanying tests cover unset, shorthand, object, true, auto, and false states. (ui/src/pages/labs/labs-registry.ts:47, b3ae33f03a25)
  • Real behavior proof: The PR body and follow-up comment show after-fix terminal output from the actual resolver and harness tool-surface runtime with omitted configuration: a catalog-preferred Anthropic model engages Code Mode, while an unflagged Ollama model retains its normal tool surface. (src/agents/code-mode-runtime.ts:153, b3ae33f03a25)
  • Merged feature provenance: The related merged PR introduced the existing "auto" tier and per-model catalog eligibility, while explicitly deferring this default flip; this branch is the narrow follow-up rather than a parallel implementation. (src/agents/code-mode-runtime.ts:153, 7394262cd137)
  • Documentation contract: The branch updates runtime schema help and user documentation to state that the default is "auto", that false opts out, and that true remains the force-on setting. Public docs: docs/gateway/config-tools.md. (docs/gateway/config-tools.md:84, b3ae33f03a25)

Likely related people:

  • steipete: The supplied related merged PR shows this contributor introduced the current per-model Auto tier and catalog eligibility mechanism that this follow-up now makes the default. (role: introduced the merged Auto-tier behavior and recent area contributor; confidence: high; commits: 7394262cd137, b3ae33f03a25; files: src/agents/code-mode-runtime.ts, ui/src/pages/labs/labs-registry.ts, docs/tools/code-mode.md)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-28T03:52:20.992Z sha 1af3683 :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Addressing the ClawSweeper before-merge items:

Real behavior proof (added to the PR body Evidence section): ran the actual runtime decision surface from this head (resolveCodeModeConfig + createAgentHarnessToolSurfaceRuntime) with tools.codeMode entirely omitted from config, against real bundled catalog entries:

resolveCodeModeConfig({}).enabled = "auto"
engaged(preferred anthropic/claude-sonnet-5) = true
engaged(unflagged ollama/kimi-k2.5)   = false
anthropic/claude-sonnet-5 (preferred): codeModeControlsEnabled=true model-visible tools=["exec","wait"]
ollama/kimi-k2.5 (unflagged): codeModeControlsEnabled=false model-visible tools=["read","web_search","sessions_list"]

The preferred model (extensions/anthropic/openclaw.plugin.json, compat.codeMode: "preferred") engages and its model-visible surface collapses to exec/wait; the unflagged Ollama model keeps its normal tool list byte-identical. This is the omitted-config default path plus the non-preferred control case.

Upgrade-risk framing: the newly engaged path is not new code — it is the same code-mode surface already shipped behind enabled: true/"auto" (introduced by 7394262, PR #114695) with fail-closed semantics: if the QuickJS-WASI runtime is unavailable, an engaged run fails instead of silently degrading, exactly as documented. Only catalog-preferred (explicitly evaluated) models change surface; tools.codeMode.enabled: false is the one-line opt-out and the Labs switch exposes it as Off.

Owner confirmation: this default flip is the explicit owner product decision that PR #114695 deferred; this PR was created under that direct owner instruction, and the intentional upgrade-behavior change is stated plainly in the PR body's User Impact section.

@steipete
steipete force-pushed the feat/code-mode-auto-default-af7b branch from 1af3683 to b3ae33f Compare July 28, 2026 04:52
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 28, 2026
@steipete
steipete merged commit c903ca8 into main Jul 28, 2026
194 of 204 checks passed
@steipete
steipete deleted the feat/code-mode-auto-default-af7b branch July 28, 2026 07:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant