Invalid type: tool_result

I built a backend API using Agno and FastAPI. Everything worked fine when I used claude-sonnet-4-20250514. However, when I switched to gpt-4.1-mini-2025-04-14, the following error message occurred. I have no idea what caused this error. Could you please help me check it? Thank you.

Configuration

Platform: MacOS
Agno: 1.7.6
FastAPI: 0.115.13
OpenAI: 1.93.0

Error Message

Invalid value: ‘tool_result’. Supported values are: ‘text’, ‘image_url’, ‘input_audio’, ‘refusal’, ‘audio’, and ‘file’.

Traceback

Traceback (most recent call last):
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/models/openai/chat.py”, line 390, in ainvoke
return await self.get_async_client().chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/openai/resources/chat/completions/completions.py”, line 2454, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/openai/_base_client.py”, line 1784, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/openai/_base_client.py”, line 1584, in request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: “Invalid value: ‘tool_result’. Supported values are: ‘text’, ‘image_url’, ‘input_audio’, ‘refusal’, ‘audio’, and ‘file’.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘messages[7].content[0].type’, ‘code’: ‘invalid_value’}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py”, line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py”, line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/fastapi/applications.py”, line 1054, in call
await super().call(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/applications.py”, line 112, in call
await self.middleware_stack(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py”, line 187, in call
raise exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py”, line 165, in call
await self.app(scope, receive, _send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 176, in call
with recv_stream, send_stream, collapse_excgroups():
File “/Users/evanbai/.local/share/uv/python/cpython-3.11.12-macos-aarch64-none/lib/python3.11/contextlib.py”, line 158, in exit
self.gen.throw(typ, value, traceback)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_utils.py”, line 82, in collapse_excgroups
raise exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 178, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/app/api/common/middlewares/logging_middleware.py”, line 10, in dispatch
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 156, in call_next
raise app_exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 141, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 176, in call
with recv_stream, send_stream, collapse_excgroups():
File “/Users/evanbai/.local/share/uv/python/cpython-3.11.12-macos-aarch64-none/lib/python3.11/contextlib.py”, line 158, in exit
self.gen.throw(typ, value, traceback)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_utils.py”, line 82, in collapse_excgroups
raise exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 178, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/app/api/common/middlewares/requestid_middleware.py”, line 11, in dispatch
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 156, in call_next
raise app_exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/base.py”, line 141, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py”, line 85, in call
await self.app(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py”, line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py”, line 53, in wrapped_app
raise exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py”, line 42, in wrapped_app
await app(scope, receive, sender)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/routing.py”, line 714, in call
await self.middleware_stack(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/routing.py”, line 734, in app
await route.handle(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/routing.py”, line 288, in handle
await self.app(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/routing.py”, line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py”, line 53, in wrapped_app
raise exc
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py”, line 42, in wrapped_app
await app(scope, receive, sender)
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/starlette/routing.py”, line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/fastapi/routing.py”, line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/fastapi/routing.py”, line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/app/api/modules/completion/completion_controller.py”, line 25, in completion
return await service.completion(dto.model, dto.prompt)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/app/api/modules/completion/completion_service.py”, line 60, in completion
response = await agent.arun(message=prompt, stream=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/agent/agent.py”, line 1554, in arun
raise last_exception
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/agent/agent.py”, line 1511, in arun
response = await self._arun(
^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/agent/agent.py”, line 1213, in _arun
model_response: ModelResponse = await self.model.aresponse(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/models/base.py”, line 449, in aresponse
await self._aprocess_model_response(
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/models/base.py”, line 609, in _aprocess_model_response
response = await self.ainvoke(
^^^^^^^^^^^^^^^^^^^
File “/Users/evanbai/Code/aigc.pub/backend/.venv/lib/python3.11/site-packages/agno/models/openai/chat.py”, line 423, in ainvoke
raise ModelProviderError(
agno.exceptions.ModelProviderError: Invalid value: ‘tool_result’. Supported values are: ‘text’, ‘image_url’, ‘input_audio’, ‘refusal’, ‘audio’, and ‘file’.

Hi @evanbai, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

Hi @evanbai , Can you share your agent config so that I can replicate the issue ?
Thanks