Return error response for unknown tool calls instead of silently skipping#1689
Merged
dgageot merged 1 commit intodocker:mainfrom Feb 11, 2026
Merged
Return error response for unknown tool calls instead of silently skipping#1689dgageot merged 1 commit intodocker:mainfrom
dgageot merged 1 commit intodocker:mainfrom
Conversation
There was a problem hiding this comment.
Review Summary
No issues found in the changed code. The PR correctly implements error responses for unknown tool calls and simplifies the tool resolution logic.
Changes Verified:
- Bug fix: Unknown tool calls now receive proper error responses instead of being silently skipped, which fixes the LLM API contract violation
- Code simplification: The new two-step flow (availability check → handler selection) is clearer than the previous nested structure
- Test coverage: The test was appropriately updated to verify the new error response behavior
The refactoring maintains the same functionality while making the code more maintainable and fixing a real bug where tool calls without matching responses could confuse the model.
…ping Two improvements: 1. Bug fix - unknown tool calls get an error response instead of being silently dropped. On main, when the model calls a tool that doesn't exist (the else branch), the call is skipped with no tool response message added to the session. This leaves a tool_call without a matching tool_response, which violates the LLM API contract and can cause errors or confused model behavior on the next turn. This commonly happens after a handoff: agent A sees tool calls from agent B in the conversation history and tries to use them. Now it gets a clear error telling it the tool isn't available. 2. Simpler structure - one availability check instead of two separate rejection paths. On main, the availability logic has three branches with two different rejection paths. The new code separates this into two sequential steps: check agentToolMap once (reject if missing), then pick the handler. This removes the nested if, deduplicates the rejection logic, and makes the flow read top-down: is it available ‚Üí how do we run it ‚Üí run it. Assisted-By: cagent
b16e284 to
a4d5bfe
Compare
rumpl
approved these changes
Feb 11, 2026
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.
Two improvements:
Bug fix - unknown tool calls get an error response instead of being silently dropped. On main, when the model calls a tool that doesn't exist (the else branch), the call is skipped with no tool response message added to the session. This leaves a tool_call without a matching tool_response, which violates the LLM API contract and can cause errors or confused model behavior on the next turn. This commonly happens after a handoff: agent A sees tool calls from agent B in the conversation history and tries to use them. Now it gets a clear error telling it the tool isn't available.
Simpler structure - one availability check instead of two separate rejection paths. On main, the availability logic has three branches with two different rejection paths.
The new code separates this into two sequential steps: check agentToolMap once (reject if missing), then pick the handler. This removes
the nested if, deduplicates the rejection logic, and makes the flow read top-down: is it available ‚Üí how do we run it ‚Üí run it.
Assisted-By: cagent