Repository navigation
feat: keep a redacted excerpt of failed tool output (#79) - #158
Merged
Merged
Conversation
Where the adapters grade a tool call, a failed one now keeps the first 200 characters of its output on the event: redacted first, then gated by the same leak scan generated text passes - an excerpt that still looks like a leak is dropped entirely, and successful calls keep nothing. Claude Code reads it from the tool_result content, Codex from the call output, Cursor from the app database, where the query takes the first 400 characters only for failed calls and the consent says so.
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Adapters record that a tool call failed but not why. Now, wherever an adapter grades a tool call, a failed call keeps the first 200 characters of its output on the event (
errorExcerpt), redacted — so Reflex can learn which fixes go with which errors.The guard is double: the output is redacted first (
redactTruncated, which redacts a 1,224-character window before cutting, so a secret crossing the limit is seen whole), and the excerpt must then passfindLeaks()— the same leak scan generated text passes. An excerpt that still looks like a leak is dropped entirely, not just trimmed. Successful calls keep nothing.Per adapter:
tool_resultcontent (string or text blocks) of a failed result; sidechain results get the same treatment.function_call_output/local_shell_call_output/custom_tool_call_outputwhenexitFailed()says so.erroror a non-zero exit code, gated in SQL with aCASE), and the adapter redacts down to 200. The consent question says so plainly now: "for failed calls the first 200 characters of the error output, redacted — never messages, and never the output of a call that succeeded." This changes the feat: read tool outcomes from Cursor's app database (#71) #142 promise ("never tool output") — the issue listed Cursor, the extraction is gated to failures and redacted before storage, anddocs/security.mdstates the new surface exactly.markResulttakes the optional excerpt; a sharederrorExcerpt()lives incommon.tswithtextContent()(moved from Codex's local helper) so all three adapters share one implementation.Docs
docs/security.md(the Cursor app database row: what is selected for failed calls, the redaction and the leak gate),docs/architecture.md(a "Failed tool calls keep an excerpt" paragraph: per-adapter sources, the double guard, and that no skill/memory/handbook is generated from it).Testing
pnpm lint,pnpm typecheck,pnpm build,pnpm test: 757 passed, 18 skipped.common.test.ts: the excerpt is ≤200, redacted (an npm token in output is gone), and dropped when a leak survives (git@github.com: Permission denied—git@is excluded from the email redaction by design, so the email-shaped leak fails the gate);textContentreads strings and text blocks.claude.test.ts: a failed result with a token in its output keeps a redacted ≤200 excerpt; agit@…failure stays markedisErrorbut keeps no excerpt; a successful result keeps neither.codex.test.ts: a failed call's output yields the same.cursor-outcomes.test.ts: a failed call's output reaches the reader (400 chars, pre-redaction) and lands redacted on the event; a succeeded call's output never appears; the failed file event carries one too. The old "never output text" test now asserts the new contract: output only for failed calls.