Skip to content

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 10, 2026

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

@dgageot dgageot requested a review from a team as a code owner February 10, 2026 18:37
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Bug fix: Unknown tool calls now receive proper error responses instead of being silently skipped, which fixes the LLM API contract violation
  2. Code simplification: The new two-step flow (availability check → handler selection) is clearer than the previous nested structure
  3. 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
@dgageot dgageot merged commit cb7cf3e into docker:main Feb 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants