fix(approval): surface pending-approval state with explicit marker (#28000)#28323
Merged
Conversation
…sible to LLM When a tool call requires user approval in the non-blocking gateway path, the LLM previously received a result that was indistinguishable from a failed tool call (exit_code=-1, error=message). The LLM could not tell whether the tool was pending approval, had returned empty results, or had failed silently — causing it to burn context on wrong hypotheses. Fix changes the result format to include: - status: pending_approval (clear state name) - approval_pending: True (explicit boolean for LLMs to detect) - error: cleared to empty string (removes misleading error signal) This lets the LLM reason about approval latency vs actual errors, short-circuiting the previous silent failure mode. Fixes #14806
1 task
Contributor
🔎 Lint report:
|
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.
Salvage of #28000 by @LifeJiggy.
What: When a tool requires approval (e.g. write_file, patch on sensitive paths), the approval prompt fires asynchronously but the tool result returned to the LLM was indistinguishable from a normal failure (
exit_code=-1plus a generic error string). The model couldn't tell whether to retry, wait, or give up.How: Promote the status field from
approval_requiredtopending_approvaland add an explicitapproval_pending: Truefield on both the guard payload (tools/approval.py) and the terminal-tool fallthrough (tools/terminal_tool.py). Clears theerrorfield so the model sees the pending state directly instead of as a failure.Original PR: #28000
Fixes #14806.