Repository navigation
fix: mask secrets before live tool-result delivery - #146596
Conversation
|
🦞👀 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. Reviewed September 12, 2026, 10:58 PM ET / September 13, 2026, 02:58 UTC (Revision 5). ClawSweeper reviewWhat this changesMasks finalized tool-result text before the next model request and preserves those masked bytes through transcript storage without adding a public SDK method. Merge readiness✅ Ready for maintainer review This PR remains useful: current main lacks the live masking step, and the older related PR closed unmerged. Both prior concerns are resolved, with no remaining actionable defect found. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's agent session receives tool results after extension processing, publishes events, and saves transcripts. The prepared result then feeds the model's next request and subsequent conversation replay. flowchart LR
A[Tool output or error] --> B[Extension processing]
B --> C[Session text masking]
D[Secret registry and patterns] --> C
C --> E[Listeners and revalidation]
E --> F[Transcript storage]
E --> G[Next model request]
F --> H[Conversation replay]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +169, Tests +614, Docs +7. Total +790 across 18 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep masking at finalized session-result admission, reuse the established text policy, and preserve prepared bytes without expanding the plugin API. Do we have a high-confidence way to reproduce the issue? Yes, at source level: an ordinary read or exec result containing a registered secret can reach the next model request on current main without live masking. No runtime reproduction was executed during this review. Is this the best way to solve the issue? Yes. Preparing finalized text after extension processing covers shared tool outcomes while retaining execution arguments, media, and the existing redaction policy; the previous public-API expansion is removed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f0817f23e939. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
c0dc370 to
8139a27
Compare
|
Addressed the text-field masking finding: preparation now applies the same complete model-visible text-field policy that persistence uses. The new unregistered app-password regression failed before the correction and passes for the first actual provider payload and SQLite close/reopen; benign source text remains intact. The 326 focused tests and independent review passed. The branch also includes main's separate upgrade-cohort test correction; that 18-test owner suite and the 13 end-to-end payload/restoration cases pass on the refreshed base. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The API-scope concern is resolved: the new public The SDK type regression fails with the former method and passes after removal. All 70 focused tests pass, including 13 first-continuation/SQLite policy cases, plus types, lint, import/export guards and a fresh independent review through P2. The authenticated Anthropic file-read continuation passes after this cutover. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* fix: mask secrets before live tool-result delivery * fix: preserve field-aware masking in live tool text * refactor(agents): keep tool-result preparation internal
…142821) - P1: connect the encoding to the existing transcript owner. transcript-redact-text.ts escapes raw literals, marks the masks redaction produces, and keeps sanitized output when no mask was produced; transcript-redact.ts routes source-input text through the same encoder; the caller-less transcript-redact-values.ts module is removed. - P1: the persisted-detail sanitizer keeps truncation and partial-secret omission output even when it produced no mask, so an unterminated private-key fragment can no longer be restored into persisted details. - P2: a literal-only complete marker is stored escaped (no genuine mark), so replay keeps the user's bytes instead of replacing them; tests cover the no-fresh-mark case the helper test skipped by adding a genuine mark. Model-visible tool text keeps the delivery dialect (bare masks) because those bytes are admitted live by prepareModelVisibleToolTextBlock (openclaw#146596), and identity comparisons use the canonical (unmarked) form: delivery-mirror dedupe, append identity and Claude CLI import dedupe no longer compare marked bytes against unmarked ones. Re-redacting stored bytes is not a byte fixed point (a hint body is mask-shaped text), so a second pass collapses a hint to a marked placeholder; the row stays masked, replayable and secret-free.
Related: #71211
What Problem This Solves
Fixes: secrets in tool output can reach the next model request even when the saved transcript masks them.
User Impact
User impact: the OpenClaw harness masks recognized and registered secrets in live tool-result text, while preserving ordinary source text, media, and the original arguments used to execute tools.
Why This Change Was Made
Apply the effective session redaction policy after extension transformations and revalidate the current result around callbacks. Preserve prepared bytes through storage and restoration only while the text, pattern policy, and registered-secret revision still match. The existing session runtime registry binds this policy internally; no public SDK method, new settings, or native Codex behavior changes.
Evidence
Real read and exec regressions failed before the repair and pass afterward for Anthropic Messages and OpenAI Responses. Coverage includes extension replacements, errors, media preservation, and SQLite close/reopen. Checks also cover explicit pattern overrides, late secret registration, non-idempotent custom patterns, and unregistered app-specific passwords using the complete existing text-field policy. Typechecks, lint, repository guards, and independent review passed. An authenticated Anthropic file-read continuation passed without the synthetic credential in its request payload.
Final API-scope cleanup: 70 focused tests, SDK type contracts, types/lint/import/export guards, and fresh independent review through P2 passed. The authenticated Anthropic continuation passed again after this cutover.