Skip to content

Fix false positive billing error detection in agent messages#76

Open
moscowchill wants to merge 1 commit intoKeygraphHQ:mainfrom
moscowchill:fix/billing-detection-false-positive
Open

Fix false positive billing error detection in agent messages#76
moscowchill wants to merge 1 commit intoKeygraphHQ:mainfrom
moscowchill:fix/billing-detection-false-positive

Conversation

@moscowchill
Copy link

@moscowchill moscowchill commented Feb 7, 2026

Summary

  • detectApiError() was checking full assistant message content including serialized tool_use JSON
  • When agents wrote security reports containing terms like "usage limit" or "rate limit", the billing error patterns matched on report content inside Write tool calls, killing the agent with a false BillingError
  • Added extractTextOnlyContent() that filters out tool_use blocks so only the agent's actual text responses are checked for billing patterns

Test plan

  • Verified agent no longer crashes with false billing error when writing security reports containing "limit"/"cap" keywords
  • Confirmed pipeline progresses through Phase 3 report writing without false positive
  • Unit test for extractTextOnlyContent filtering tool_use blocks

🤖 Generated with Claude Code

detectApiError() was checking the full assistant message content including
serialized tool_use JSON. When agents wrote security reports containing
terms like "usage limit" or "rate limit", the billing error patterns
matched on report content inside Write tool calls, killing the agent.

Add extractTextOnlyContent() that filters out tool_use blocks so only
the agent's actual text responses are checked for billing patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant