fix(agents): suppress unrecognized errors from user surface#324
Open
BingqingLyu wants to merge 3 commits intomainfrom
Open
fix(agents): suppress unrecognized errors from user surface#324BingqingLyu wants to merge 3 commits intomainfrom
BingqingLyu wants to merge 3 commits intomainfrom
Conversation
The final fallback in formatAssistantErrorText returned raw error text to the user when no known error pattern matched. This leaked internal API error details (e.g. orphaned tool call errors, provider-specific diagnostics) to messaging surfaces. Replace the fallback with a generic user-safe message and log the original error for debugging. Related openclaw#11038, openclaw#16948 ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
Address review feedback: - Add auth and model-not-found checks before the generic catch-all so actionable guidance survives retry exhaustion (Codex P2) - Redact sensitive text (API keys, tokens) in log preview using existing redactSensitiveText utility (Aisle High CWE-532) - Strip CR/LF from log preview to prevent log forging (Aisle Low CWE-117) ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
- Check isCliSessionExpiredErrorMessage before auth (bare "expired" in auth patterns would misclassify "session expired" as auth failure) - Check isImageDimensionErrorMessage before catch-all to preserve actionable resize guidance instead of generic "Something went wrong" ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
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.
Summary
formatAssistantErrorTextfalls through to a final branch that returns raw, unrecognized error strings (truncated at 600 chars) directly to the chat surface. This leaks API internals, confuses users, and spams channels.tool_resulterrors, rate limits, and other unexpected API responses become visible to end users in Telegram/Slack/etc.overloaded,rate_limit,too_many_tokens, etc.) are untouched — only the unrecognized catch-all is affected.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Unrecognized errors that previously leaked raw API messages to the chat surface now show a generic user-friendly message. The raw error is still logged at
warnlevel for debugging.Security Impact (required)
Repro + Verification
Environment
Steps
tool_resultwithout matchingtool_use)Expected
Actual
warnlevel.Evidence
New test in
formatassistanterrortext.test.tsverifies the unrecognized-error branch returns the generic message. Lifecycle test expectations updated.Human Verification (required)
Review Conversations
N/A — fresh PR, no review conversations yet.
Compatibility / Migration
Failure Recovery (if this breaks)
errors.tsto restore the raw-truncation fallback.src/agents/pi-embedded-helpers/errors.tsRisks and Mitigations
warnlevel. Operators can see it in logs.✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)