fix(engine): redact tool_result output in chat-grounding (#8869) - #9105
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
foldAssistantMessage runs every outgoing text chunk through the PUBLIC_FIELD_BLOCKLIST backstop, but foldToolResultMessage forwarded an MCP tool's own output verbatim -- so a blocklisted field in a tool's result leaked into the public-facing chat-grounding stream unredacted. Scan the tool_result content (string, content-block array, or object where the term can appear as a key or value) against the same blocklist and, on a hit, replace the whole output with the redaction sentinel -- matching redactBlockedText's replace-not-filter policy.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9105 +/- ##
==========================================
- Coverage 93.88% 93.88% -0.01%
==========================================
Files 810 810
Lines 80600 80606 +6
Branches 24454 24458 +4
==========================================
+ Hits 75675 75677 +2
Misses 3560 3560
- Partials 1365 1369 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 18:04:46 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Problem
Closes #8869.
packages/loopover-engine/src/miner/chat-grounding.tsdocuments a redaction invariant: every outgoing chunk is checked againstPUBLIC_FIELD_BLOCKLISTand redacted.foldAssistantMessagehonors it (redactBlockedText(block.text)), butfoldToolResultMessageforwardedblock.content— an MCP tool's own output — verbatim, with no redaction. A blocklisted field (wallet,payout,trust score, …) in a tool's result therefore leaked straight into the public-facing chat-grounding stream.Fix
Scan the tool_result content against the same
PUBLIC_FIELD_BLOCKLISTbefore yielding, and on a hit replace the whole output withCHAT_REDACTED_TEXT— matchingredactBlockedText's established replace-not-filter policy. The scan handles every shape a tool result takes: a plain string, an SDK content-block array, or an object where the blocked term appears as a key (apayoutfield) or nested in a value. Clean output of any shape passes through unchanged.Test
test/unit/chat-grounding-engine.test.ts(the codecov-visible vitest that imports the engine source) adds a case drivingrunChatGroundingwith blocked tool_result content in each shape — string, content-block array, and nested object key — asserting each is replaced with the sentinel, while clean string / array / primitive outputs pass through verbatim. 100% patch coverage (statements + branches) on the changed file. The existing clean-{}pass-through test is unaffected.