Skip to content

fix(agents): expose filesystem tool results in Code Mode - #110395

Merged
steipete merged 1 commit into
mainfrom
codex/code-mode-filesystem-tool-contracts
Jul 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/code-mode-filesystem-tool-contracts

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Code Mode callers reading ordinary files through tools.callValue("openclaw:core:read", ...) received undefined, so file content could not be composed into later calls. The same high-volume workflow also lacked declared result contracts for edits and patch application.

Why This Change Was Made

Read now returns a closed, discriminated details union for text, image, truncation, and optional-not-found outcomes after adaptive paging and image normalization. Edit declares explicit changed/no-op variants, while apply_patch declares its added/modified/deleted path summary. Session tool adapters preserve these tool-local TypeBox contracts.

The read return value is an intentional compatibility change for Code Mode. Existing optional-not-found fields remain available, with an additive kind discriminator. Rendered content blocks remain unchanged.

AI-assisted. I reviewed the whole result path, callers, renderers, sibling contract pattern, tests, TypeBox behavior, and the Code Mode bridge.

User Impact

Code Mode can now read ordinary file text as a structured value and compose it without dropping to the raw result envelope. It can also branch reliably on edit no-ops versus real changes and inspect apply_patch summaries from the quick index.

Release note: Code Mode filesystem tools now expose structured read, edit, and apply_patch results for composition.

Evidence

  • Exact head: 5c9a9fb3327bc3241dc83e6efd4452a37b24a88d
  • Blacksmith Testbox: 7 focused files, 166 tests passed, including a real QuickJS-WASI tools.callValue("openclaw:core:read", ...) round trip and executed-result Value.Check coverage for every read/edit variant plus apply_patch: https://github.com/openclaw/openclaw/actions/runs/29629586159
  • pnpm check:changed passed core/core-test typechecks, formatting, exhaustive core lint, plugin boundaries, import-cycle checks, and repository guards on the same patch before the conflict-free rebase.
  • Exact compact output-hint snapshots cover all three contracts.
  • Fresh exact-head autoreview: clean, no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 1:22 AM ET / 05:22 UTC.

Summary
The branch adds structured TypeBox output contracts and normalized result details for read, edit, and apply_patch filesystem tools so Code Mode can consume them through tools.callValue.

PR surface: Source +197, Tests +139, Docs +3. Total +339 across 13 files.

Reproducibility: yes. from source and supplied proof: the new Code Mode test exercises the prior failure path by calling the wrapped read tool through tools.callValue, where uncontracted result details were not exposed as a value.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/agents/code-mode.test.ts, serialized state: src/agents/filesystem-tools-output-contract.test.ts, serialized state: src/agents/sessions/extensions/types.ts, serialized state: src/agents/sessions/tools/edit.ts, serialized state: src/agents/sessions/tools/read.ts, serialized state: src/agents/sessions/tools/tool-contracts.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain maintainer confirmation that ToolDefinition.outputSchema is the intended stable Code Mode result-contract seam.
  • [P2] Let the current-head required checks complete before merging.

Risk before merge

  • [P1] Merging establishes ToolDefinition.outputSchema as a shared session-tool contract surface; plugins or future tool adapters may rely on its meaning, so the ownership and stability expectations should be consciously accepted rather than inferred from this filesystem use case.

Maintainer options:

  1. Confirm the shared result-contract seam (recommended)
    Merge only after an owner confirms that ToolDefinition.outputSchema is intended to be a stable shared contract for Code Mode result values.
  2. Constrain the filesystem implementation
    If that shared contract is not intended, replace the generic propagation with a narrower owner-local bridge before merging.
  3. Pause the API expansion
    Leave the PR open while maintainers decide whether this new session-tool contract belongs in the permanent API surface.

Next step before merge

  • [P2] A protected maintainer label and the unresolved shared API-boundary choice require human acceptance; no narrow mechanical repair is currently identified.

Maintainer decision needed

  • Question: Should ToolDefinition.outputSchema become the supported shared contract boundary for exposing session-tool AgentToolResult.details to Code Mode?
  • Rationale: The patch is mechanically focused and proven, but this optional field changes the long-term API/ownership boundary for session tool definitions rather than only repairing one filesystem implementation.
  • Likely owner: steipete — The supplied context shows steipete owns the proposed implementation and is assigned to the PR; feature-history ownership beyond this PR could not be established from the available material.
  • Options:
    • Accept the shared seam (recommended): Approve the optional outputSchema propagation as the canonical Code Mode structured-result contract and merge after normal current-head checks complete.
    • Keep the contract local: Ask for a narrower filesystem-specific bridge if maintainers do not want session tool definitions to expose this shared result-schema capability.
    • Pause for API design: Defer the PR until the plugin/session-tool contract and documentation ownership are explicitly decided.

Security
Cleared: The proposed diff changes agent tool schemas, adapters, tests, and documentation without adding dependencies, workflow execution, permissions, secret handling, or artifact-download behavior.

Review details

Best possible solution:

Accept one documented shared outputSchema contract boundary for Code Mode only if maintainers intend session-defined tools to expose stable structured details; otherwise keep the filesystem result schemas local until the owning adapter seam is chosen.

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

Yes, from source and supplied proof: the new Code Mode test exercises the prior failure path by calling the wrapped read tool through tools.callValue, where uncontracted result details were not exposed as a value.

Is this the best way to solve the issue?

Unclear until maintainers confirm the shared contract boundary. The normalization and schema coverage are a focused fix for the observed Code Mode path, but the best permanent owner for outputSchema is an API-direction decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 923d92bdd0e3.

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: The PR adds an optional shared session-tool output contract whose semantics may become relied upon by existing or future tool adapters.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Code Mode filesystem-result fix with useful but non-emergency agent-runtime impact.
  • merge-risk: 🚨 compatibility: The PR adds an optional shared session-tool output contract whose semantics may become relied upon by existing or future tool adapters.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body links a focused Testbox run that includes an after-fix QuickJS-WASI tools.callValue round trip; this directly demonstrates the changed Code Mode behavior, and the supplied context marks the PR proof: sufficient.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body links a focused Testbox run that includes an after-fix QuickJS-WASI tools.callValue round trip; this directly demonstrates the changed Code Mode behavior, and the supplied context marks the PR proof: sufficient.
Evidence reviewed

PR surface:

Source +197, Tests +139, Docs +3. Total +339 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 227 30 +197
Tests 4 139 0 +139
Docs 1 9 6 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 375 36 +339

What I checked:

  • Code Mode behavior proof: The PR adds a QuickJS-WASI Code Mode test that calls tools.callValue("openclaw:core:read", { path: "notes.txt" }) and asserts ordinary file content is returned as structured details. (src/agents/code-mode.test.ts:1006, 2db349512d64)
  • Result-contract coverage: The branch adds direct TypeBox validation coverage for text, image, truncation, optional-not-found, edit, and apply-patch result variants, matching the new output schemas. (src/agents/filesystem-tools-output-contract.test.ts:1, 2db349512d64)
  • Shared contract boundary: ToolDefinition gains an optional outputSchema, and the generic tool-definition wrappers propagate it. This makes the change broader than a local read-tool normalization fix. (src/agents/sessions/extensions/types.ts:503, 2db349512d64)
  • Maintainer-review context: The prior completed ClawSweeper cycle found no mechanical defect but identified acceptance of the shared output-schema boundary as the remaining decision; the current PR is labeled maintainer and assigned to its proposer. (2db349512d64)
  • Provided validation evidence: The PR body links an exact-head Testbox run with 166 focused tests and a real Code Mode round trip; GitHub context also records proof: sufficient and successful focused quality/security checks, while broader CI remains in progress. (2db349512d64)

Likely related people:

  • steipete: The supplied PR context identifies steipete as the sole branch commit author and current assignee; no separate current-main feature-history attribution was available in the provided review material. (role: feature proposer and current assignee; confidence: low; commits: 2db349512d64; files: src/agents/sessions/extensions/types.ts, src/agents/agent-tools.read.ts, src/agents/code-mode.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-18T04:04:23.525Z sha 5c9a9fb :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Jul 18, 2026
@steipete
steipete force-pushed the codex/code-mode-filesystem-tool-contracts branch from 5c9a9fb to 2db3495 Compare July 18, 2026 05:19
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 18, 2026
@steipete
steipete merged commit b9c5c7c into main Jul 18, 2026
131 of 135 checks passed
@steipete
steipete deleted the codex/code-mode-filesystem-tool-contracts branch July 18, 2026 05:26
@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 docs Improvements or additions to documentation maintainer Maintainer-authored PR 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: M 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