Fix 400 Error with Parallel Tool Calls (LiteLLM Adapter) #231
+18
−5
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.
API calls via the LiteLLM adapter failed with a 400 Bad Request when models like OpenAI returned multiple tool_calls (requesting parallel execution). The adapter incorrectly sent only one tool response message back, while the API requires a separate tool message for each requested tool_call_id.
Cause:
The _get_completion_inputs function in lite_llm.py only processed the first function_response part from the ADK's aggregated tool response event, ignoring subsequent ones.
Solution:
Modified _get_completion_inputs to iterate through all function_response parts in the aggregated event. It now correctly generates a distinct ChatCompletionToolMessage (role: 'tool') for each tool_call_id.
Impact:
Resolves the 400 Bad Request error. Ensures correct message formatting for the API when handling parallel tool calls, enabling agent flows with multiple simultaneous tool executions.