Skip to content

fix(agents): keep exec visible for lean local models#101607

Merged
steipete merged 2 commits into
mainfrom
codex/replay-87587-direct-exec
Jul 7, 2026
Merged

fix(agents): keep exec visible for lean local models#101607
steipete merged 2 commits into
mainfrom
codex/replay-87587-direct-exec

Conversation

@steipete

@steipete steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Lean local-model mode defaults structured Tool Search on, which catalogs every non-control tool. That also hid exec, so coding-tuned local models could see only the Tool Search controls even when policy allowed shell access. This replays the useful part of #87587 against current main; the contributor branch is stale and does not allow maintainer edits.

This addresses only the direct-shell-visibility slice of #86632. It does not claim that every local model will choose correct commands or successfully retrieve live data.

Why This Change Was Made

The existing catalog-compaction owner already accepts a per-tool predicate. This change adds one lean-model predicate and passes it through both runtime owners: the embedded attempt path and the shared harness bridge.

The exception is intentionally narrow:

  • only policy-filtered exec stays directly visible;
  • only resolved structured Tool Search tools mode gets the exception;
  • explicit code and directory modes retain normal compaction;
  • no alias, routing heuristic, fallback stack, or permission bypass is added.

User Impact

Lean local models can directly select exec while the rest of the normal tool catalog remains compact. Existing tool allowlists, denylists, sandboxing, approvals, and hooks still decide whether and how exec can run.

The local-model docs now state that boundary. The changelog credits @vincentkoc for the original diagnosis and implementation direction.

Evidence

  • Blacksmith Testbox, exact merged head: corepack pnpm test src/agents/local-model-lean.test.ts src/agents/harness/tool-surface-bridge.test.ts src/agents/tool-search.test.ts — 66 tests passed.
  • Regression coverage proves the embedded/harness tools surfaces keep controls plus exec, catalog read, and leave explicit code mode unchanged.
  • Repository formatter check passed for all nine changed files; git diff --check passed.
  • Fresh autoreview: clean, no accepted/actionable findings, correctness confidence 0.93.
  • Isolated live A/B with Ollama qwen3.5:9b: the lean default exposed only Tool Search controls and the model fabricated a weather answer after an empty search; direct exec visibility caused the model to select shell commands instead. The attempted commands were invalid, so this is visibility proof, not end-to-end weather-success proof.
  • Upstream contract checked: Ollama tool calling and the qwen3.5:9b model card.

Replaces #87587 while preserving contributor credit in the commit.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Jul 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecab982dfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md

### Fixes

- **Lean local model shell access:** keep `exec` directly visible beside the default structured Tool Search controls so coding-tuned local models can use their shell fallback instead of searching for missing domain tools. (#87587) Thanks @vincentkoc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the hand-written changelog entry

This normal agent fix adds an Unreleased entry even though the root Docs / Changelog rule says CHANGELOG.md is release-only and that release generation derives entries from merged PRs and direct commits (AGENTS.md:238-240). Keeping this hand-written entry risks duplicate or stale release notes; leave the release-note context in the commit/PR text and let the release generator update the changelog.

Useful? React with 👍 / 👎.

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer replay review complete. This is the best bounded fix for the verified visibility defect: it uses the existing catalog predicate seam, covers both runtime tool-surface owners, keeps only policy-filtered exec direct in structured tools mode, and leaves code/directory compaction unchanged.

Land-ready proof for exact head ecab982dfca2b50810f68f70ddda9a213622879b:

  • Blacksmith Testbox lease tbx_01kwy25q40ew4jxxbb54v1kmm0: corepack pnpm test src/agents/local-model-lean.test.ts src/agents/harness/tool-surface-bridge.test.ts src/agents/tool-search.test.ts — 66 tests passed.
  • Hosted CI run 28863017665: all 48 executed jobs passed; nine scope-based skips; no failures.
  • Process/tool-boundary CodeQL and Critical Quality checks passed.
  • Native scripts/pr review-validate-artifacts 101607 and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101607 passed with zero findings.
  • Fresh autoreview reported no accepted/actionable findings, with 0.93 correctness confidence.
  • Repository formatting and git diff --check passed.

Isolated Ollama A/B: the lean default exposed only Tool Search controls and produced a fabricated weather answer after an empty search; direct exec visibility caused the model to select shell commands. Those commands were invalid, so this proves the selection-path fix but not complete live-weather success. The broader #86632 should remain open for the separate argument-shape and end-to-end behavior gaps.

@steipete
steipete merged commit 7c0a7c8 into main Jul 7, 2026
136 of 140 checks passed
@steipete
steipete deleted the codex/replay-87587-direct-exec branch July 7, 2026 11:46
@steipete

steipete commented Jul 7, 2026

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 docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant