Skip to content

refactor(agents): retire legacy tool execution argument decoding - #140280

Merged
steipete merged 1 commit into
mainfrom
codex/legacy-tool-decoder-54-208a
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/legacy-tool-decoder-54-208a

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Agent tool dispatch still carries compatibility behavior for a retired private calling convention that current callers no longer use. That leaves cancellation, hooks and client-tool execution harder to audit and maintain. This is a maintainer-requested refactor, not a fix for the separate live-test failure described below.

Why This Change Was Made

Use the existing ToolDefinition.execute signature directly in the source and client-tool adapters, removing the legacy tuple classifier and its intermediate argument projection. Preserve signal/update forwarding, private fifth-slot preparation control, hooks, and reservation/launch/disposal ordering without adding another compatibility path.

User Impact

No intended user-visible behavior, public tool API, configuration, dependency or persistence change. Supported tool calls retain their existing callback, cancellation and execution semantics.

The five-file diff is 54 fewer production lines (+4/−58) and 366 additional net test lines (+409/−43). Test-support reductions are not counted as production savings.

Evidence

  • Focused behavior: on base 208aab3aa6f054fd5eb01218284f898d0863478e, the original ten-file suite passed 151 tests and the candidate passed 161, with no failures or skips. Coverage includes actual preparer/cancellation and client-recorder ordering, plus the current SDK tool-outcome sibling. Native inter-file scheduling differed; this is not a claim of whole-run order equivalence.
  • Final projection fixture: the first normal changed gate exposed a real TS2322 schema-type error in the new test. satisfies AgentTool alone was insufficient. The final fixture preserves its concrete TypeBox schema and shallow-spreads only the client JSON-record boundary. This changes top-level identity and drops the non-enumerable TypeBox marker while preserving the enumerable schema and nested values; it is not a type-only or whole-JavaScript-identical change. The complete projection file then passed 10 tests, without weakening assertions or deadlines.
  • Normal changed gate: node scripts/check-changed.mjs --timed passed all 29 actions on the final source tree, including core/core-test typechecking and changed-file lint. Delegated gate environment.
  • Full builds and real Code Mode flow: both configured full-product builds completed all 16 phases on the unchanged production candidate, before the final test-fixture-only schema adjustment. The first build/live invocation had one live failure after 301.058 seconds, not a pass. A separately reviewed failure-diagnostics-only test change kept the prompt, environment, provider/model, deadlines, cleanup and success assertions unchanged. Its second build/live invocation passed the named case in 7.345 seconds, with one pass and no skips. The diagnostic catch did not execute. The ordinary success path verified JSON success, Code Mode engagement, outer execution and dependent bridge calls, final DONE, exact output-file contents and subprocess completion. The original default test was restored after cleanup. This proves that invocation's package-shaped OpenAI flow, not native Codex or all-provider parity.
  • Independent review: the local/precommit review and the separate authenticated review of signed commit 5b2b2eb857c0bb683899523be00d7c0aa34d4b99 each completed four Codex passes, scoped-clean at P2 with no actionable findings. Both retained the original live failure as an explicit limitation. One exact-head launch was refused before inference by the unchanged disk-capacity guard; the authorized launch after capacity recovery completed without a reviewer fallback.

The Testbox links identify delegated proof environments. Their cancelled workflow conclusions reflect lease shutdown and are not claimed as passing exact-head GitHub CI checks; the results above are the retained native payload outcomes.

Known limitation: the first live failure remains unexplained. Its terminal agent diagnostic did not establish final CLI output or process completion, and the original catch lost subprocess failure details. The later success neither explains that failure nor proves a hang fix or causal exoneration. The named follow-up is the subprocess failure-evidence/finalization boundary; no production stage markers, timeout extension or retry loop is added here.

Exact-head CI: run 34045812043 completed successfully for signed head 5b2b2eb857c0bb683899523be00d7c0aa34d4b99. Normal native review, hosted prepare and merge remain pending.

Maintainer disposition of the live-test risk

The unresolved incident and safe-diagnostics work are tracked in #140314; neither will be declared fixed by this cleanup. The first run remains failed and unexplained. The later real application run reached every original success assertion on the same production afterimage, but is not a causal explanation.

Direct source inspection and an independent challenge confirm that current producers already supply signal third, updates fourth, and an absent/context/private-control fifth value without an aborted member. The old decoder takes its canonical branch for those inputs, yielding exactly the identities now destructured. No await, hook, cancellation composition, preparation control, callback, reservation/launch/disposal or post-result finalizer changes. This evidence and the actual successful application path support landing the bounded retirement under the normal gates; CI or review counts alone would not resolve the concern. Any new failure or supported legacy-order caller reopens this disposition.

The follow-up specifically requires a deterministic failing synthetic subprocess test for the sanitized diagnostic projection. The successful diagnostic invocation never entered its catch, so it does not prove that failure path. No raw streams, credentials, timeout increase, runtime marker or retry loop is added to this PR.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 16:33
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 1:18 PM ET / 17:18 UTC.

ClawSweeper review

What this changes

The PR removes legacy tool-call argument decoding and adds coverage for cancellation, update forwarding, execution ordering, and session completion.

Merge readiness

✅ Ready for maintainer review

The cleanup remains useful and introduces no identified correctness blocker. Current callers support the canonical argument order, and the updated maintainer disposition addresses the previous review concern while preserving the separate live-failure investigation.

Priority: P3
Reviewed head: 5b2b2eb857c0bb683899523be00d7c0aa34d4b99

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with meaningful preservation coverage and a successful real application run; the earlier incident has an explicit, bounded disposition.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): Captured evidence reports the unchanged production candidate completing the real package-shaped agent exec Code Mode flow through tool dispatch, dependent filesystem calls, final JSON, and process exit; source inspection matches those assertions. This demonstrates the exercised path while leaving the earlier failed invocation unexplained and separately tracked.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Captured evidence reports the unchanged production candidate completing the real package-shaped agent exec Code Mode flow through tool dispatch, dependent filesystem calls, final JSON, and process exit; source inspection matches those assertions. This demonstrates the exercised path while leaving the earlier failed invocation unexplained and separately tracked.
Evidence reviewed 7 items Introduced production change: The complete local merge-base-to-head diff removes the tuple classifier and projection while preserving signal composition, fifth-slot preparation control, hooks, and execution ordering. All five introduced files were inspected, including the test patch omitted from the supplied excerpt.
Canonical caller and release contract: The current ToolDefinition contract places signal third, updates fourth, and context fifth. The wrapper uses that order both at the reviewed head and in v2026.9.2; the inspected context factory and private preparation control do not contain an aborted member that would select the former legacy branch.
Cleanup remains absent from current main: Fetched main retains the legacy decoder; its adapter-to-head comparison matches the introduced production cleanup. The latest supplied release also retains that decoder, so neither current main nor that release supersedes this contribution.
Findings None None.
Security None None.

How this fits together

The agent tool adapter connects session dispatch to built-in and client-hosted tools. It carries arguments, cancellation, and progress callbacks through policy hooks before returning results or delegating execution to the client.

flowchart TD
  A[Session tool call] --> B[Tool definition wrapper]
  B --> C[Canonical argument adapter]
  C --> D[Policy hooks and preparation]
  D --> E{Execution destination}
  E --> F[Built-in tool]
  E --> G[Client delegation]
  F --> H[Progress and session results]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -54, Tests +366. Total +312 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 58 -54
Tests 4 410 44 +366
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 414 102 +312

Review metrics

None.

Technical review

Best possible solution:

Keep one typed tool-execution convention while preserving cancellation, callbacks, policy preparation, and client ordering; retain the diagnostics investigation as separate work.

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

Not applicable: this PR preserves existing behavior rather than repairing a reproduced defect; the separate live failure still has no established cause.

Is this the best way to solve the issue?

Yes. Directly using the existing typed signature removes redundant decoding without changing supported callers or adding a competing execution path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8476b288c17f.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Captured evidence reports the unchanged production candidate completing the real package-shaped agent exec Code Mode flow through tool dispatch, dependent filesystem calls, final JSON, and process exit; source inspection matches those assertions. This demonstrates the exercised path while leaving the earlier failed invocation unexplained and separately tracked.

Label justifications:

  • P3: This is a bounded internal cleanup with no intended change to supported user behavior.
  • 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 (linked_artifact): Captured evidence reports the unchanged production candidate completing the real package-shaped agent exec Code Mode flow through tool dispatch, dependent filesystem calls, final JSON, and process exit; source inspection matches those assertions. This demonstrates the exercised path while leaving the earlier failed invocation unexplained and separately tracked.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured evidence reports the unchanged production candidate completing the real package-shaped agent exec Code Mode flow through tool dispatch, dependent filesystem calls, final JSON, and process exit; source inspection matches those assertions. This demonstrates the exercised path while leaving the earlier failed invocation unexplained and separately tracked.

Evidence

What I checked:

  • Introduced production change: The complete local merge-base-to-head diff removes the tuple classifier and projection while preserving signal composition, fifth-slot preparation control, hooks, and execution ordering. All five introduced files were inspected, including the test patch omitted from the supplied excerpt. (src/agents/agent-tool-definition-adapter.ts:367, 5b2b2eb857c0)
  • Canonical caller and release contract: The current ToolDefinition contract places signal third, updates fourth, and context fifth. The wrapper uses that order both at the reviewed head and in v2026.9.2; the inspected context factory and private preparation control do not contain an aborted member that would select the former legacy branch. (src/agents/sessions/tools/tool-definition-wrapper.ts:34, 3928bad9badf)
  • Cleanup remains absent from current main: Fetched main retains the legacy decoder; its adapter-to-head comparison matches the introduced production cleanup. The latest supplied release also retains that decoder, so neither current main nor that release supersedes this contribution. (src/agents/agent-tool-definition-adapter.ts:310, 8476b288c17f)
  • Behavior-preservation coverage: The added tests exercise direct, wrapped, and composed cancellation/update forwarding; delayed client-hook reservation order; real preparation handles; cancellation before filesystem effects; and terminal session projections. They add no production-only testing seam. Tests were inspected, not executed during this read-only review. (src/agents/sessions/agent-session-runtime-projection.test.ts:39, 5b2b2eb857c0)
  • Real application evidence and review continuity: The captured PR body, sourceRevision b301320c8b64d78cb39fa27e07f251d261cf986c6997d3d8a2e360b362508324, reports a package-shaped OpenAI Code Mode invocation completing in 7.345 seconds with JSON success, dependent bridge calls, final DONE, exact file contents, and subprocess completion: https://github.com/openclaw/openclaw/actions/runs/34036314026. The earlier 301.058-second failure remains unexplained. The updated maintainer disposition explicitly accepts the bounded cleanup and tracks diagnostics and the incident in test: preserve safe subprocess diagnostics in agent exec live proof #140314. The previous review contained no findings, and the reviewed head is unchanged. Live GitHub/artifact retrieval was unavailable; the assessment uses the supplied captured evidence, not independently retrieved payload logs. (test/agent-exec-code-mode.live.test.ts:18, 5b2b2eb857c0)
  • Implementation and dependency boundary: The adapter imports OpenClaw's own session ToolDefinition. Documentation distinguishes generic OpenClaw Code Mode from native Codex Code Mode, and the supplied proof expressly claims only the former. No affirmative Codex dependency-contract signal requires sibling inspection. Public docs: docs/tools/code-mode.md. (docs/tools/code-mode.md:25, 5b2b2eb857c0)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-06T16:39:23.660Z sha 5b2b2eb :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 6, 2026
@steipete steipete self-assigned this Sep 6, 2026
@steipete
steipete merged commit fc1877d into main Sep 6, 2026
256 checks passed
@steipete
steipete deleted the codex/legacy-tool-decoder-54-208a branch September 6, 2026 17:57
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (25 commits)
  docs(releases): keep the release-notes nav group to version routes (#140353)
  fix(ui): hide trust wrappers in imported chat history
  fix(subagents): subagent list building decodes unrelated saved prompts in large session stores (#139540)
  test(process): share relay startup fixtures (#140345)
  refactor(doctor): inline GitHub skill discovery inputs (#140343)
  refactor(ui): share channel status type definitions (#140331)
  refactor: simplify queue state and infrastructure dispatch (#140311)
  fix: require saved agent turns before update verification succeeds (#140274)
  fix(update): keep the service profile when switching to Git (#140263)
  fix(ui): prevent image avatars overlapping mobile chat (#140341)
  fix(test): accept release subpages in docs route shape (#140337)
  refactor(plugins): share uninstall mutation ownership (#140322)
  refactor(agents): use canonical tool execution arguments (#140280)
  perf(cli): keep inference metadata and domain help lazy (#140327)
  refactor(plugins): simplify self-hosted setup results (#140332)
  refactor(config): reuse parent lookup for unset operations (#140326)
  fix(plugins): preserve exact installed-index mutation receipts (#140328)
  test(agents): simplify MCP and LSP boundary fixtures (#140312)
  fix(ui): preserve literal source previews and copied whitespace (#140306)
  fix: OpenCode Go/Zen requests are missing the required x-opencode-session header (#137464)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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