Repository navigation
fix(code-mode): serialize catalog handles nested in final values - #130276
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 4:48 PM ET / 20:48 UTC. ClawSweeper reviewWhat this changesThis PR recursively converts nested code-mode catalog tool handles into plain metadata and freezes time for one non-timeout MCP lifecycle test. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: current main still serializes only a bare handle or flat array, while this exact-head patch repairs nested and shared return values at the sole pre-dump boundary. No blocking patch defect was found. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCode mode runs guest JavaScript in QuickJS and returns its completed value to the agent. Catalog search produces callable tool handles that must be converted to plain metadata before the QuickJS result dump reaches the model. flowchart LR
A[Guest code] --> B[Catalog search]
B --> C[Callable tool handles]
C --> D[Final value serialization]
D --> E[QuickJS result dump]
E --> F[Agent and model output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +34. Total +48 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the guest-side recursive projection after normal exact-head merge checks; do not add a second host-side serialization path. Do we have a high-confidence way to reproduce the issue? Yes. Current main's flat-array serializer and the completed-result call chain establish the defect, while the focused guest regression exercises nested arrays, objects, and shared aliases. Is this the best way to solve the issue? Yes. The guest-side serializer is the last controllable transformation before QuickJS dumps the value, making this narrower than a parallel host-side serializer; the separately discussed null-prototype AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 70c87cc98d7a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
@clawsweeper re-review Maintainer disposition and verification for exact head
No known in-scope proof gaps remain. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* origin/main: (26 commits) fix(plugins): preserve registry epoch on activation rollback (#129232) refactor(plugins): make discovery invocation-owned (#130486) feat(ui): save appearance preferences per user profile (#130340) fix: Buzz bots recover relay stalls and reject revoked senders (#130467) fix(code-mode): serialize catalog handles nested in final values (#130276) fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427) fix(agents): read the published model catalog owner from session_status (#130277) fix(channels): preserve long presentation text (#130368) fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325) refactor(plugins): unify setup registration and artifact selection (#130474) fix(memory): prevent forgotten session content from returning (#130451) refactor(outbound): consolidate transport completion (#130460) fix(workers): protect in-flight workspace manifests from concurrent retention (#130449) fix(portals): keep worker previews reachable and owned by the active environment (#130434) fix(config): keep core channels keys in the generated config schema (#120736) chore(deps): refresh dependencies after seven-day cooldown (#130296) fix(agents): remind exec models to quote shell metacharacters (#125485) fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437) fix(openshell): preserve file writes during concurrent mirror commands (#130447) fix(workers): report full nodes as at capacity, not offline (#130445) ...
…nclaw#130276) * fix(code-mode): serialize catalog handles nested in final values * fix(code-mode): serialize shared catalog aliases --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: roboclaw-bot <[email protected]>
What Problem This Solves
In OpenClaw code mode,
catalog.search()results are callable handles that serialize to{callableName, toolName, ...}metadata when returned as the program's final value. That only worked for a bare handle or a flat array of handles. Any nesting —Promise.all([catalog.search(a), catalog.search(b)]), or{ tools: [...] }— dumped each handle asnull, so the model saw[[null,null,...]]and concluded no matching tool existed.Observed in a live Telegram session on 2026-08-26: three parallel searches returned 24
nulls; the model then declared its tool surface read-only and stopped, although the shellexecglobal it was searching for was present.Why This Change Was Made
serializeCatalogHandlesinsrc/agents/code-mode-controller-source.tsnow walks arrays and plain objects recursively (cycle-guarded, prototype-checked so class instances andtoJSONhooks are untouched). The cycle guard tracks the active recursion path, so shared non-cyclic containers are projected at every returned alias instead of being mistaken for cycles. Metadata projection stays the single serialization path; no new bridge surface.The previously failing MCP CI assertion now uses the test file's existing frozen-clock helper. That assertion is not testing the catalog deadline, and a concurrent identical shard passed while this PR's shard exhausted its 50 ms wall-clock deadline under CI contention.
User Impact
Nested catalog handles in a code-mode return value now surface their tool names/schemas instead of
null, including when the containing object is shared across multiple return paths. Tool discovery throughcatalog.searchtherefore composes withPromise.all, keyed results, and shared containers.Evidence
serializes catalog handles nested inside arrays and plain objectscovers a shared container through three paths; it fails before the active-path fix and passes afterward.node scripts/run-vitest.mjs src/agents/code-mode.guest.test.ts: 22 passed.node scripts/run-vitest.mjs src/node-host/mcp.test.ts: 18 passed.agents-root,other) pass.