Skip to content

fix(agent): word a blocked tool for a run nobody can approve in - #1588

Merged
edenreich merged 1 commit into
mainfrom
fix/blocked-tools-unattended-reason
Oct 20, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/blocked-tools-unattended-reason

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

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, KillShell and BrowserNavigate as 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. advertisedTools deliberately 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 BashOutput on 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: blockedReason with the new wording and an optional hint.
  • internal/agent/loop/states/agent_events.go: BlockedToolHint on 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.
  • Test: TestBlockingToolsState_ReasonFitsAnUnattendedRun.

no docs ticket: docs/tool-approval.md already says headless blocks when no approver is reachable

Verification

task precommit:run clean, go test ./... green, internal/agent/loop/... under -race.

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.
@edenreich
edenreich requested a review from a team as a code owner October 20, 2026 18:48
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Oct 20, 2026
@edenreich
edenreich merged commit 81d632f into main Oct 20, 2026
1 check passed
@edenreich
edenreich deleted the fix/blocked-tools-unattended-reason branch October 20, 2026 19:05
@edenreich edenreich moved this from Todo to Done in 2026 Oct 20, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.233.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Approval-gated tools are offered when no approver exists and block the agent mid-turn

1 participant