Repository navigation
fix: keep unused Code Mode lookups from tainting memory - #201519
Conversation
Co-authored-by: vincentkoc <[email protected]>
Worked on by: - @vincentkoc Co-authored-by: vincentkoc <[email protected]> OpenClaw-Publication: 8916587d-3637-4ea5-bc69-68ba8b3f4238
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes Code Mode discovery taint depend on metadata exposure and forwards dynamic result provenance to the memory observer. Example: An owner turn searches for remote_metadata, leaves its handle unused, then writes memory/catalog.md in a later cell.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused repair for unnecessary memory quarantine that remains on current main, and no introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCode Mode translates guest catalog operations into host tool calls; exposure markers flow through result formatting into transcript taint and memory-write classification. flowchart LR
A[Guest catalog search] --> B[Lazy callable handles]
B --> C[Metadata exposure tracking]
C --> D[Result provenance]
D --> E[Host turn observer]
E --> F[Memory classification]
Technical reviewBest possible solution: Keep the existing lazy exposure tracker and shared result-provenance mechanism as the sole sources for this distinction. Do we have a high-confidence way to reproduce the issue? Current-main source establishes eager catalog-hit marking and transcript taint; the PR supplies a production-wrapper memory regression and reports red/green verification, which this read-only review did not execute. Is this the best way to solve the issue? The patch is the smallest complete repair for the stated boundary: remove redundant eager observation, consume the existing dynamic provenance fact, and retain distinct exposure regressions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 07baab52b414. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +89, Docs +7. Total +101 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 18, 2026, 6:41 PM ET / 23:41 UTC. |
Closes #196857
What Problem This Solves
Unused Code Mode tool lookups could mark an entire turn as external content and quarantine session-memory snapshots. At the same time, the host memory-write observer missed Code Mode’s per-result provenance and could leave genuinely consumed external metadata trusted.
User Impact
Unused discovery no longer makes later owner-requested memory writes untrusted. Consumed or emitted external metadata, MCP declarations, and network tool results retain their existing provenance protections. Previously quarantined files are not reclassified; there is no migration or configuration change.
Why This Change Was Made
Code Mode returns lazy callable handles, so its guest already records when external metadata is read or serialized. Stop eagerly marking unused search hits, and forward the existing per-result provenance to the host’s memory-taint observer instead of looking only at static tool metadata. Ordinary Tool Search, execution, stored-value provenance, and memory classification policy are otherwise unchanged.
Evidence
git diff --checkpassed. Fullpnpm buildpassed (2m 58s), followed by a finalpnpm build:runtime(1m 8s); it reported non-fatal Control UI asset-budget warnings in unchanged UI code.agentmemory; consuming the external description produced fenced output anduntrustedmemory. The Gateway, sockets, and temporary state were cleaned up. Live test: 36.65 seconds wall time.Simplification: remove the duplicate eager observation and reuse the existing internal result-source fact. No new state, owner, public option, trust exception, or provenance mechanism. Production delta: +8/-3 lines; tests: +91/-2; docs: +7. The small production growth forwards the existing source fact into the memory observer.
Contributor credit
Reported by @Ricardodpalmeida. Fix requested and directed by @vincentkoc.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by