Skip to content

fix(core): hide glob, grep, and webfetch for every model under full_codemode - #64906

Merged
jlongster merged 3 commits into
devfrom
codemode-hide-search-tools
Nov 19, 2026
Merged

jlongster merged 3 commits into
devfrom
codemode-hide-search-tools

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

With full_codemode on, glob, grep and webfetch are now hidden for every model, not only GPT and Claude.

#64364 made those three tools unregister themselves when the flag was on, for all models. #64515 later moved tool selection into modelTools in tool/model-policy.ts and dropped those per-tool checks, but only hid the tools for GPT and Claude. Since then GLM, DeepSeek, Gemini and other models get them back under the flag. This restores the all-models behavior inside modelTools, so it also applies when no model is resolved.

Nothing changes with the flag off: the tools stay direct for every model, as before.

How did you verify your code works?

  • bun test test/tool-model-policy.test.ts (updated expectations, plus a new case covering GPT, Claude, DeepSeek, GLM, Gemini and no model): 8 pass
  • bun test test/tool-registry.test.ts test/tool-search.test.ts test/codemode.test.ts: 70 pass

Screenshots / recordings

n/a

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@jlongster
jlongster force-pushed the codemode-hide-search-tools branch from 6d912de to 1ab2c08 Compare November 19, 2026 16:04
…odemode

User decisions:
- With full_codemode on, always hide grep and glob for every model

@opencodejr opencodejr 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.

The fix is correct. With full_codemode on, glob, grep and webfetch are now hidden for every model and when no model is resolved. With the flag off, nothing changes.

I checked it by running the updated tool-model-policy.test.ts against the base source: 3 tests fail there, and the end-to-end SessionContext.select case still gives DeepSeek glob, grep and webfetch. With the PR, those tests and the registry, search and Code Mode tests pass, and typecheck:tsc is clean.

Public API: unchanged.

Please address:

  • bun.lock: the PR drops every "libc" field from the native packages (@opencode/pty-linux-*, @opentui/core-linux-*-musl, @oxc-parser/binding-linux-*, and so on). It looks like it came from a Bun version other than the pinned bun@1.4.4. It's unrelated to the fix and could change which glibc/musl binaries get installed, so please revert it.
  • Abattoir page: packages/core/src/tool/AGENTS.md asks that changes to modelTools also update the copied logic in Abattoir (src/guides/oc-model-tools.ts and the model-tools page text). This change alters the rule for non-GPT/Claude models.
  • Explore agent: see the inline comment.

const direct = new Set<string>()
if (!input.websearch) hidden.add("websearch")
// Code Mode programs search and fetch through shell and their `fetch` global, so these tools only add noise.
if (input.fullCodeMode) for (const name of fullCodeModeHidden) hidden.add(name)

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.

This widens the known open item from #64515. The explore agent blocks execute, so with the flag on, explore sessions for every model now lose glob, grep and webfetch without getting Code Mode in return. They can still search through shell, but they have no fetch tool at all. Before, only GPT and Claude were affected. Is that intended, or should these stay visible when execute isn't available to the agent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intended for agents that can use Code Mode only. Fixed in 5040657: with the flag on, an agent that can't run execute (like explore) gets the flag-off policy, so glob, grep and webfetch stay top-level tools. session/context.ts now passes fullCodeMode && Tool.codeModeAvailable(permissions) to modelTools, and Tool.snapshot uses the same helper. Added cases for GPT and DeepSeek with execute denied.

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.

I checked 5040657 and the fix works. modelTools has one caller, session/context.ts:170, and it now gets fullCodeMode && Tool.codeModeAvailable(permissions). The snapshot's codeModeEnabled check in tool.ts uses the same helper. Both places use the same execute rule: the last rule matching execute is resource: "*" + deny. So an agent without execute can no longer lose glob, grep and webfetch while also being left without Code Mode. The new GPT and DeepSeek cases with execute denied cover this.

What I ran, in a temporary worktree at pr/head that I've since removed:

  • bun test test/tool-model-policy.test.ts test/tool-registry.test.ts test/tool-search.test.ts test/codemode.test.ts: 78 pass.
  • tsc --noEmit in packages/core: clean.

I didn't trace how the real explore agent's permission set denies execute. Any rule that ends in a *-resource deny for execute, including a catch-all * deny, hits this path. An agent that denies execute only for some resources still counts as having Code Mode, so the tools stay hidden. That matches how the snapshot already behaves.

The shared repo/ checkout is still at 1ab2c0841, without this commit. I didn't change it.

@opencodejr opencodejr 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.

The unrelated bun.lock rewrite is gone, so the diff is now just the policy change and its test. The code is the same as in the commit I reviewed before, and tool-model-policy.test.ts still passes. The public API is unchanged.

The explore-agent thread is still open. The Abattoir model-tools page that packages/core/src/tool/AGENTS.md asks to keep in sync with modelTools still needs updating.

…un execute

User decisions:
- With the flag on and execute disabled, glob, grep and webfetch stay as top-level tools
@jlongster

Copy link
Copy Markdown
Contributor Author

Thanks, addressed:

  • bun.lock: reverted. It came from a local bun install; the PR now only touches the policy code and tests.
  • Abattoir page: updated in anomalyco/abattoir#99 (copied modelTools and the page text).
  • Explore agent: with the flag on and execute disabled, glob, grep and webfetch now stay top-level tools; with execute available they're hidden for every model (5040657).

tool-model-policy, tool-registry, tool-search, codemode, session-runner and tool-subagent tests pass (345 total).

User decisions:
- Simplify the confusing early returns in modelTools
@jlongster
jlongster enabled auto-merge (squash) November 19, 2026 16:20
@jlongster
jlongster merged commit fb40f64 into dev Nov 19, 2026
10 checks passed
@jlongster
jlongster deleted the codemode-hide-search-tools branch November 19, 2026 16:20

@opencodejr opencodejr 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.

The new commits fix the explore-agent point. Agents that can't run execute now get the flag-off policy, so glob, grep and webfetch stay direct for them. The check is the same one Tool.snapshot uses, so the two can't drift apart. The refactor of modelTools gives the same results as before in every case I traced. The four core tool suites pass and typecheck:tsc is clean.

Public API: unchanged. Tool.codeModeAvailable is a new export, but only core uses it.

The Abattoir model-tools page mirror required by packages/core/src/tool/AGENTS.md still needs updating.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant