fix(agent): halt on non-retryable tool billing blockers - #20691
Closed
dlkakbs wants to merge 1 commit into
Closed
Conversation
Contributor
|
Thanks for the thoughtful writeup and the tests — the underlying symptom (tools hitting a dead billing wall burning iterations) is real and worth fixing. That said, I'm going to close this one. After reviewing, detecting billing blockers via substring-matching tool result strings inside the generic guardrail layer has too many false-positive failure modes to ship:
If you'd like to take another pass: narrow detection to the specific tool wrappers that can actually produce 402/credit-exhausted responses, emit a typed failure from those, and have the guardrail react to the typed signal rather than a substring heuristic. Happy to review a followup along those lines. |
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
When a tool returns a clear non-retryable billing/credits failure like:
Payment RequiredInsufficient creditsInsufficient quotaHermes currently feeds that tool result back to the model and keeps iterating. In practice this can burn extra iterations/tokens, retry the same dead path, and delay a clear user-visible explanation of the blocker.
This PR changes that behavior:
Why
This is aimed at cases like
web_searchreturningPayment Required / Insufficient credits, where continuing the same strategy is non-productive and the correct action is to surface the blockerimmediately.
Before this PR:
After this PR:
Implementation
agent/tool_guardrails.pyrun_agent.pyTests
Ran:
pytest tests/agent/test_tool_guardrails.py -qpytest tests/run_agent/test_tool_call_guardrail_runtime.py -qRelated
Related but not duplicate:
Historical context: