[BUG] OpenAI and Ollama adapters send an empty tool message when a tool returns a dict
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
Línea de trabajo
Comienza con _extract_function_response_content en python/packages/kagent-adk/src/kagent/adk/models/_openai.py y _extract_response_content en python/packages/kagent-adk/src/kagent/adk/models/_ollama.py; ambos devuelven una cadena vacía para resultados dict sin una lista content ni una clave result. Ejecuta el script de reproducción desde python/ con uv run python repro.py para ver los mensajes de herramienta vacíos. Está terminado cuando ambos auxiliares serializan con JSON otros dicts (igual que el extractFunctionResponseContent de Go) y la reproducción muestra que el contenido del dict llega al modelo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
📋 Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
- I am using the latest version of the software
- I have tried to clear cache/cookies or used incognito mode (if ui-related)
- I can consistently reproduce this issue
🎯 Affected Service(s)
App Service
🚦 Impact/Severity
Blocker
🐛 Bug Description
When a tool returns a dict, the Python OpenAI and Ollama adapters send the model an empty tool message. The model never sees what the tool returned.
ADK passes a dict returned by a tool through unchanged (only non-dict results are wrapped as {"result": ...}), so this covers:
- any tool that returns a dict, like the
{"status": "success", "report": ...}style used in the ADK docs - ADK's own error responses, e.g.
{"error": "Invoking get_weather() failed as the following mandatory input parameters are not present: city ..."}for a missing argument, an unknown tool name, or a rejected confirmation. The model is supposed to read these and retry, but it gets an empty message instead. - kagent's own tools that return dicts, e.g.
ask_user({"status": "pending", ...}) and the remote A2A tool ({"status": "failed", "error": ...})
Both helpers only handle a string, a dict with a content list (MCP results), or a dict with a result key, and return "" for everything else:
python/packages/kagent-adk/src/kagent/adk/models/_openai.py,_extract_function_response_content. Used for Chat Completions and the Responses API, so OpenAI, Azure OpenAI, Foundry and Mistral are all affected.python/packages/kagent-adk/src/kagent/adk/models/_ollama.py,_extract_response_content
The Go ADK (extractFunctionResponseContent in go/adk/pkg/models/base.go) JSON-encodes other dicts, and the Python Bedrock and SAP AI Core adapters also send the dict as text, so only these two Python helpers drop it.
🔄 Steps To Reproduce
This runs a real ADK agent with kagent's OpenAI model against a small local fake OpenAI server that records the tool messages it receives. The fake model calls get_weather first without its argument, then with it.
import asyncio, json, threading
from http.server import BaseHTTPRequestHandler, HTTPServer
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from google.genai import types
from kagent.adk.models._openai import OpenAI
calls = ["{}", '{"city": "Paris"}'] # first without the required argument, then with it
sent = []
class FakeOpenAI(BaseHTTPRequestHandler):
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
sent[:] = [m for m in body["messages"] if m["role"] == "tool"]
if calls:
msg = {"role": "assistant", "content": None, "tool_calls": [{"id": f"call_{len(sent) + 1}", "type": "function",
"function": {"name": "get_weather", "arguments": calls.pop(0)}}]}
else:
msg = {"role": "assistant", "content": "Done."}
data = json.dumps({"id": "x", "object": "chat.completion", "created": 0, "model": "gpt-4o",
"choices": [{"index": 0, "message": msg, "finish_reason": "stop"}]}).encode()
self.send_response(200); self.send_header("Content-Length", str(len(data))); self.end_headers(); self.wfile.write(data)
def log_message(self, *args): pass
def get_weather(city: str) -> dict:
"""Get the current weather for a city."""
return {"status": "success", "report": f"Sunny, 25C in {city}"}
async def main():
server = HTTPServer(("127.0.0.1", 0), FakeOpenAI)
threading.Thread(target=server.serve_forever, daemon=True).start()
model = OpenAI(type="openai", model="gpt-4o", api_key="test", base_url=f"http://127.0.0.1:{server.server_port}/v1")
runner = InMemoryRunner(agent=Agent(name="weather", model=model, tools=[get_weather]), app_name="demo")
session = await runner.session_service.create_session(app_name="demo", user_id="u")
msg = types.Content(role="user", parts=[types.Part.from_text(text="Weather in Paris?")])
async for event in runner.run_async(user_id="u", session_id=session.id, new_message=msg):
for part in event.content.parts if event.content else []:
if part.function_response:
print(f"tool result in ADK : {part.function_response.response}")
for m in sent:
print(f"sent to the model : tool message for {m['tool_call_id']} -> content={m['content']!r}")
asyncio.run(main())
Run it from python/ with uv run python repro.py.
🤔 Expected Behavior
The model receives the tool result, e.g. the dict serialized as JSON:
sent to the model : tool message for call_1 -> content='{"error": "Invoking `get_weather()` failed ..."}'
sent to the model : tool message for call_2 -> content='{"status": "success", "report": "Sunny, 25C in Paris"}'
📱 Actual Behavior
tool result in ADK : {'error': 'Invoking `get_weather()` failed as the following mandatory input parameters are not present:\ncity\nYou could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.'}
tool result in ADK : {'status': 'success', 'report': 'Sunny, 25C in Paris'}
sent to the model : tool message for call_1 -> content=''
sent to the model : tool message for call_2 -> content=''
The tool ran and ADK has both results, but both tool messages sent to the model are empty.
💻 Environment
- OS and version: macOS 26.4 (arm64)
- Application version:
mainat 12aa4d46, Python 3.13.15, google-adk 2.12.0 - Kubernetes: not needed to reproduce (runs locally against a fake OpenAI server)
🔧 CLI Bug Report
No response
🔍 Additional Context
A possible fix is to fall back to json.dumps(response, default=str) in both helpers instead of returning "", which matches what the Go ADK does. I'd be happy to open a PR with that and unit tests for both adapters, if that sounds right.
📋 Logs
📷 Screenshots
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
- Lenguaje dominante
- Go
- Estrellas
- 4.1k
- Forks
- 871
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 183
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de kagent-dev/kagent
-
Gemini catalogs omit gemini-4-argon and gemini-3.8-flashPosiblemente ocupada @jayunit100 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
kagent-dev/kagent#3524 ·
Los mantenedores suelen responder en 1 día
-
Bedrock model catalog does not suggest all providers in the same granularityPosiblemente ocupada @jayunit100 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
kagent-dev/kagent#3514 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 81/100
kagent-dev/kagent#3507 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
kagent-dev/kagent#3428 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG]Posiblemente ocupada @helloxjade la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
kagent-dev/kagent#3385 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de kagent-dev/kagent
Issues similares
-
WriterSetTimes: the UTIME_NOW check fails when the kernel uses its coarse clockPosiblemente ocupada @JakeChampion la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
JakeChampion/lang#14224 ·
Los mantenedores suelen responder en 1 día
-
docs(reference): pi stream-filter bullet says tool_execution_update passes through unchangedAbiertoagent-butler-finding bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
jordansmall/spindrift#6391 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
SAP/crossplane-provider-btp#1175 ·
Los mantenedores suelen responder en 1 día
-
Broken links in the docsAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
adk: stream concatenation errors bypass retry and failoverPosiblemente ocupada @OUAO-FRANK la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día