Repository navigation
V38: Let createAgent sanitize tool error text sent to the model - #694
Merged
Merged
Conversation
LinuxDevil
force-pushed
the
v38-tool-error-message
branch
from
October 20, 2026 03:27
852ee02 to
f6eee8c
Compare
Adds an opt-in createAgent({ toolErrorMessage }) that replaces the message of
a thrown tool error (kind 'execution') before the model, tool.error events and
hooks see it. A throwing sanitizer yields a generic message.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LinuxDevil
force-pushed
the
v38-tool-error-message
branch
from
October 20, 2026 06:54
979b332 to
de08fb3
Compare
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.
Fixes audit finding AI-9 (Vercel competitor audit, 2026-10-19).
What was wrong
A tool that throws
new Error("DB password=hunter2 connection refused")sent that text verbatim to the model and the event stream; there was no hook to redact it.What changed
createAgent({ toolErrorMessage: (error, { toolName, toolCallId }) => string })(also anExecuteOptionsfield, inherited by sub-agents, and honored on the post-approval resume path).messageforkind: 'execution'errors. The same sanitized text reachestool.errorevents,onToolResultandpostToolCallhooks, so client-facing streams never carry the original; only the sanitizer sees the thrown error (log it there).The tool failed.; the run continues.Tests
toolErrorResult.test.ts: secret text replaced for model andtool.errorevent (kind stays execution); validation error untouched and sanitizer not called; throwing sanitizer gives generic message and run completes; no option behaves as before. Ran tsc, typecheck:tests, lint, api:check, docs:llms:check, fallow (exit 0) and test:coverage; the coverage run's only failures were load/Windows flakes (wrangler dev, tracing, kit-pi) that pass in isolation.Changelog: Added
createAgent({ toolErrorMessage })to sanitize thrown tool error text before it reaches the model, events and hooks.🤖 Generated with Claude Code