Fix gemini tools call

This commit is contained in:
Nicolas Mowen 2026-04-29 16:14:26 -06:00
parent 11bb9fed4c
commit 3c19eba7c4

View File

@ -143,15 +143,17 @@ class GeminiClient(GenAIClient):
) )
elif role == "tool": elif role == "tool":
# Handle tool response # Handle tool response
function_response = { response_payload = (
"name": msg.get("name", ""), content if isinstance(content, dict) else {"result": content}
"response": content, )
}
gemini_messages.append( gemini_messages.append(
types.Content( types.Content(
role="function", role="function",
parts=[ parts=[
types.Part.from_function_response(function_response) # type: ignore[misc,call-arg,arg-type] types.Part.from_function_response(
name=msg.get("name", ""),
response=response_payload,
)
], ],
) )
) )
@ -350,15 +352,17 @@ class GeminiClient(GenAIClient):
) )
elif role == "tool": elif role == "tool":
# Handle tool response # Handle tool response
function_response = { response_payload = (
"name": msg.get("name", ""), content if isinstance(content, dict) else {"result": content}
"response": content, )
}
gemini_messages.append( gemini_messages.append(
types.Content( types.Content(
role="function", role="function",
parts=[ parts=[
types.Part.from_function_response(function_response) # type: ignore[misc,call-arg,arg-type] types.Part.from_function_response(
name=msg.get("name", ""),
response=response_payload,
)
], ],
) )
) )