Skip to content

refactor(agent): remove the dead executeTool approval route - #1160

Merged
edenreich merged 4 commits into
mainfrom
refactor/unify-tool-rejection-route
Sep 2, 2026
Merged

edenreich merged 4 commits into
mainfrom
refactor/unify-tool-rejection-route

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Resolves #1153.

The older executeTool approval route was dead: EvaluatingToolsState sends any batch containing an approval-requiring tool to ApprovingTools/BlockingTools, so executeToolCallsParallel only ever received batches needing no approval. Its re-check of the policy, createRejectionEntry, and the hasRejection turn-stop in handleToolResults were unreachable and had drifted from the live path.

  • Delete the partition/approval loop in executeToolCallsParallel, the approval branch of executeTool, createRejectionEntry, and the rejection branch of handleToolResults. checkToolResultsStatus becomes checkPlanApproval.
  • buildRejectionEntry (states) is now the single rejection-entry builder; finishApprovals via AnyToolRejected is the single stop-the-turn rule.
  • Document ToolExecutionResult.Rejected: human rejection ends the turn, judge rejection is a plain failure so the driver continues.
  • New TestExecuteToolCallsParallel_NeverRequestsApproval pins that the route never consults the policy or prompts.

Test plan

  • go test ./internal/agent/... -race
  • task precommit:run

The state machine's EvaluatingToolsState is the only approval gate: it
routes batches with approval-requiring tools to ApprovingTools or
BlockingTools, so executeToolCallsParallel only ever received batches
that need none. Its re-check of the approval policy, createRejectionEntry
and the hasRejection turn-stop in handleToolResults were unreachable and
had drifted from the live path.

Delete them, leaving buildRejectionEntry as the single rejection builder
and finishApprovals/AnyToolRejected as the single stop-the-turn rule.
Document on ToolExecutionResult.Rejected that it marks a human rejection
which ends the turn, while a judge rejection is a plain failure.

Closes #1153
@edenreich
edenreich requested a review from a team as a code owner September 2, 2026 19:54
Comment thread internal/agent/domain/tool_contracts.go Resolved
@edenreich
edenreich merged commit 1e41d13 into main Sep 2, 2026
1 check passed
@edenreich
edenreich deleted the refactor/unify-tool-rejection-route branch September 2, 2026 20:14
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.188.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 2, 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

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor unify the two tool-approval and rejection routes

1 participant