Repository navigation
refactor(agents): resolve code-mode vs tool-search once for every harness - #115189
Merged
Merged
Conversation
…arness The code-mode vs tool-search gate decision and the three-way catalog application were duplicated across the embedded runner and the native harness bridge, and had already drifted: the harness copy was missing the skillWorkshopProposalOnly condition and its params object had no field to express it. Both surfaces now consume resolveAgentToolSurfacePlan and applyAgentToolSurfaceCatalog, so the gates and the catalog branch exist once. Both gate booleans derive from a single shared toolsAvailable intermediate. Behavior change: the harness path now honors skillWorkshopProposalOnly. Proposal-only skill-workshop runs are deliberately narrow single-tool runs, so code-mode indirection and tool-search catalogs are pure overhead — a harness-independent reason. Both callers currently pin agentHarnessRuntimeOverride "openclaw", so this closes a latent fail-open rather than fixing a live bug.
resolveAgentToolSearchRuntimeConfig returns OpenClawConfig | undefined, so requiring a non-null toolSearchRuntimeConfig broke tsgo:core at both call sites. Keep the key required so it cannot be silently omitted, but let the value be undefined as the pre-refactor code already allowed.
steipete
marked this pull request as ready for review
July 28, 2026 12:32
Importing isCodeModeEngagedForModel and applyToolSchemaDirectoryCatalog from their defining modules left the code-mode.ts and tool-search.ts re-exports with no production consumer, which knip rejects. Go back through the barrels, which is also what both call sites did before this refactor. The two params types were exported only for the test, so knip's production scan saw them as dead. Keep them module-local and derive the type in the test.
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 29, 2026
…ness (openclaw#115189) * refactor(agents): share one tool-surface resolver across runner and harness The code-mode vs tool-search gate decision and the three-way catalog application were duplicated across the embedded runner and the native harness bridge, and had already drifted: the harness copy was missing the skillWorkshopProposalOnly condition and its params object had no field to express it. Both surfaces now consume resolveAgentToolSurfacePlan and applyAgentToolSurfaceCatalog, so the gates and the catalog branch exist once. Both gate booleans derive from a single shared toolsAvailable intermediate. Behavior change: the harness path now honors skillWorkshopProposalOnly. Proposal-only skill-workshop runs are deliberately narrow single-tool runs, so code-mode indirection and tool-search catalogs are pure overhead — a harness-independent reason. Both callers currently pin agentHarnessRuntimeOverride "openclaw", so this closes a latent fail-open rather than fixing a live bug. * fix(agents): let the shared catalog params carry a config-less run resolveAgentToolSearchRuntimeConfig returns OpenClawConfig | undefined, so requiring a non-null toolSearchRuntimeConfig broke tsgo:core at both call sites. Keep the key required so it cannot be silently omitted, but let the value be undefined as the pre-refactor code already allowed. * fix(agents): keep the tool-surface module free of dead exports Importing isCodeModeEngagedForModel and applyToolSchemaDirectoryCatalog from their defining modules left the code-mode.ts and tool-search.ts re-exports with no production consumer, which knip rejects. Go back through the barrels, which is also what both call sites did before this refactor. The two params types were exported only for the test, so knip's production scan saw them as dead. Keep them module-local and derive the type in the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
The decision of whether a run gets Code Mode, a Tool Search catalog, or the raw
tool surface was implemented twice — once in the embedded agent runner and once
in the native harness bridge that Copilot runs on. The two copies had already
drifted: the harness copy was missing the
skillWorkshopProposalOnlycondition,and its params object had no field to express it, so the divergence could not be
seen from the harness side at all.
The three-way catalog application (Code Mode / schema-directory / Tool Search)
was likewise duplicated nearly verbatim across the same two surfaces, including
the invariant that a policy-required
messagetool must stay directly visible.Why This Change Was Made
Both surfaces now consume one resolver,
resolveAgentToolSurfacePlan, plus onecatalog applier,
applyAgentToolSurfaceCatalog. Both gate booleans derive from asingle shared
toolsAvailableintermediate, so Code Mode and Tool Search cannotdrift apart again, and the "message tool must stay directly visible" invariant is
stated once. The old inline copies are deleted rather than kept alongside.
createCodeModeToolsintentionally stays at each call site: its argumentsgenuinely differ (
forceRestartSafeTools,codeModeSkills), so sharing it wouldadd an adapter that only renames fields.
Deliberate behavior decision:
skillWorkshopProposalOnlynow applies to theharness path too. A proposal-only skill-workshop run is a deliberately narrow
single-tool run (
toolsAllow: ["skill_workshop"],disableMessageTool: true,lightweight bootstrap), so Code Mode indirection and a Tool Search catalog are
pure overhead — a reason that does not depend on which harness runs the turn.
Both proposal-only callers currently pin
agentHarnessRuntimeOverride: "openclaw"(
src/skills/workshop/history-scan-review.ts,src/skills/workshop/experience-review.ts), so this closes a latent fail-openrather than fixing a live bug.
Non-goal: the Codex app-server, which has its own
codexDynamicToolsLoadingpath and is untouched. Also out of scope: the separate client-tools catalog
branch in
attempt-client-tools.ts, which has no harness sibling.User Impact
No user-visible change on any shipped path. Operators keep the same Code Mode
and Tool Search behavior they have today; the one behavior difference is that a
skill-workshop proposal-only run routed through a native harness would now keep
the raw tool surface instead of engaging Code Mode, matching what the embedded
runner has always done.
Plugin authors implementing a native harness gain one optional pass-through
field,
skillWorkshopProposalOnly, documented indocs/plugins/sdk-agent-harness.md.Evidence
Proven on Blacksmith Testbox lease
tbx_01kymabq83q54fp4x3vmg9404x(
exitCode: 0,runStatus: "succeeded"):pnpm tsgo:core,pnpm tsgo:extensions,pnpm tsgo:testpnpm test src/agents/embedded-agent-runner/run— 71 files, 928 tests passedextensions/copilot/src/tool-bridge.test.ts— 77 tests passedsrc/agents/tool-surface-plan.test.ts+src/agents/harness/tool-surface-bridge.test.ts— 25 tests passed
New coverage: the embedded runner's gate conditions previously had no focused
test.
src/agents/tool-surface-plan.test.tstable-drives each suppressing input(model tools disabled,
disableTools, raw model run, ring-zero run, emptyexplicit allowlist,
skillWorkshopProposalOnly), asserts Code Mode and ToolSearch stay mutually exclusive, and pins which applier each mode selects.
tool-surface-bridge.test.tsadds a harness-level test proving a proposal-onlyrun keeps the raw tool surface with no
exec/wait.Per
src/agents/embedded-agent-runner/run/AGENTS.md, this deliberately adds nonew full
runEmbeddedAttempttest; the helper is production-called and testeddirectly.