fix(agents): snapshot SDK custom tools safely#89404
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 8:25 PM ET / 00:25 UTC. Summary PR surface: Source +70, Tests +109. Total +179 across 4 files. Reproducibility: yes. Source inspection on current main shows createAgentSession directly reads tool.name and AgentSession later rereads descriptor metadata, so hostile SDK getters can throw before or during session setup. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one maintainer-approved custom-tool descriptor contract: accept process-stable SDK snapshots for this narrow PR, or reconcile it into a broader canonical quarantine branch before merging. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows createAgentSession directly reads tool.name and AgentSession later rereads descriptor metadata, so hostile SDK getters can throw before or during session setup. Is this the best way to solve the issue? Unclear as a merge decision. Snapshotting at SDK/session ingress is a clean bounded fix if process-stable descriptors are accepted, but maintainers still need to choose that SDK compatibility contract against the broader branches. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e87b0df67575. Label changesLabel justifications:
Evidence reviewedPR surface: Source +70, Tests +109. Total +179 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (1 earlier review cycle)
|
38301c5 to
3025863
Compare
|
Closing this one. The PR has no tracked issue and explicitly comes from the fuzzing sweep; its SDK tests manufacture mutable/throwing descriptor accessors rather than a real custom-tool integration. Snapshotting and rebinding every SDK tool changes object identity and method semantics for a hypothetical state. Keep the typed SDK contract strict; add a narrow ingestion check only if a real external caller demonstrates the need. Thanks for investigating receiver preservation. |
Summary
createAgentSessionor block healthy sibling tools.execute, renderers, and argument preparation.This is scoped to SDK/session custom tool ingestion. It does not change provider-side schema normalization or extension registration policy.
Linked context
No tracked issue. Part of the tool-schema/runtime ingress fuzzing sweep.
Real behavior proof (required for external PRs)
node scripts/run-vitest.mjs src/agents/sessions/sdk.test.ts -- --reporter=dot;./node_modules/.bin/oxfmt --check --threads=1 src/agents/sessions/sdk.ts src/agents/sessions/agent-session.ts src/agents/sessions/tools/tool-definition-wrapper.ts src/agents/sessions/sdk.test.ts;OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/sessions/sdk.ts src/agents/sessions/agent-session.ts src/agents/sessions/tools/tool-definition-wrapper.ts src/agents/sessions/sdk.test.ts;git diff --check origin/main...HEAD;.agents/skills/autoreview/scripts/autoreview --mode local; AWS Crabbox fresh PROPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed.src/agents/sessions/sdk.test.tspassed 8/8 after the rebase; oxfmt, targeted oxlint, diff-check, and autoreview were clean. AWS Crabboxrun_48879f533e2fon leasecbx_7c36dafccedd(c7a.8xlarge) passedpnpm check:changedwith lanescore, coreTests, exit 0.name,promptGuidelines, andparametersgetters are dropped before startup whilehealthy_lookupremains active; stateful custom tool methods keep their original receiver.ui/configinputs are not present there; the same lane passed in the full Crabbox fresh PR checkout.options.customTools?.map((tool) => tool.name)directly, so a throwingnamegetter crashed beforeAgentSessioncould be built.Tests and validation
Focused commands run:
node scripts/run-vitest.mjs src/agents/sessions/sdk.test.ts -- --reporter=dot./node_modules/.bin/oxfmt --check --threads=1 src/agents/sessions/sdk.ts src/agents/sessions/agent-session.ts src/agents/sessions/tools/tool-definition-wrapper.ts src/agents/sessions/sdk.test.tsOPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/sessions/sdk.ts src/agents/sessions/agent-session.ts src/agents/sessions/tools/tool-definition-wrapper.ts src/agents/sessions/sdk.test.tsgit diff --check origin/main...HEAD.agents/skills/autoreview/scripts/autoreview --mode localRegression coverage added:
Risk checklist
YesNoYesReflect.applyagainst the original descriptor, and a receiver-preservation regression test covers the compatibility shape.Current review state
Next action: maintainer review.
Waiting on: CI/maintainer review.
Reviewer comments addressed: local
$autoreviewinitially flagged receiver loss; the patch now preserves receivers and the rerun reported no accepted/actionable findings.