Repository navigation
fix(agent): word a blocked tool for a run nobody can approve in - #1588
Merged
Merged
Conversation
A tool that needs an approval no one can give was refused with "tell the user what you need", which an unattended agent cannot do, so it planned around the tool for the rest of the run. The refusal now says the tool stays unavailable for the whole run, not to ask the user, to work with tools that need no approval and to report what could not be done. A Bash call carries the sandbox hint on what would be allowed. The approval policy docblock said headless bypasses approval. It does not: the decision is the same, and a gated call is blocked where nobody can approve.
Contributor
|
🎉 This PR is included in version 0.233.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Closes #1583.
In a session where no approver is reachable (CI, headless without a broker) a gated tool call is refused with "Do not retry the same call - tell the user what you need and why". An unattended agent cannot tell anyone, so on the run in the issue it treated
BashOutput,KillShellandBrowserNavigateas something to work around and spent turns and context doing so.The refusal now says what is true for that session: the tool stays unavailable for the whole run, do not call it again and do not ask the user, do the work with tools and commands that need no approval, and say in the final message what could not be done and why. A blocked Bash call carries the sandbox's hint on what would have been allowed (
sandbox.BashCommandRejectionHint), the same text the Bash tool itself gives for a command off the allow-list.Not changed, and why
The issue also suggested dropping approval-gated tools from the tool list sent to the model.
advertisedToolsdeliberately sends the same list in every mode so a mode switch never invalidates the provider's prompt cache, and the headless panel can switch the agent mode mid-session (internal/presentation/headless/panel.go), so a list that depends on the mode would break that. The list stays as it is.Whether
BashOutputon a shell the agent started should need approval at all is a product decision and is not touched.Changes
internal/agent/loop/states/blocking_tools.go:blockedReasonwith the new wording and an optional hint.internal/agent/loop/states/agent_events.go:BlockedToolHinton the state context.internal/agent/loop/agent_event_driven.go: wires the Bash hint.internal/agent/loop/approval_policy.go: the docblock said headless bypasses approval, which the code does not do. It now describes the blocking behaviour.examples/tools/README.md: the example output line.TestBlockingToolsState_ReasonFitsAnUnattendedRun.no docs ticket:
docs/tool-approval.mdalready says headless blocks when no approver is reachableVerification
task precommit:runclean,go test ./...green,internal/agent/loop/...under-race.