Input tag 'reasoning' found using 'type' does not match any of the expected tags
The following error is in google cloud console. Probably due to mixing openai models and then claude code models in the same chat.
Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "messages.1.content.0: Input tag 'reasoning' found using 'type' does not match any of the expected tags: 'document', 'image', 'redacted_thinking', 'search_result', 'server_tool_use', 'text', 'thinking', 'tool_result', 'tool_use', 'web_search_tool_result'"}, 'request_id': 'req_011CUb3xNyghQuQCRtyCYy8A'}
Full log
Traceback (most recent call last):
File "/home/aigateway/app/duo_workflow_service/agents/chat_agent.py", line 228, in run
agent_response = await self._get_agent_response(input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/duo_workflow_service/agents/chat_agent.py", line 133, in _get_agent_response
return await self.prompt_adapter.get_response(input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/duo_workflow_service/agents/prompt_adapter.py", line 142, in get_response
return await self.prompt.ainvoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/ai_gateway/prompts/base.py", line 221, in ainvoke
result = await super().ainvoke(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5454, in ainvoke
return await self.bound.ainvoke(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3091, in ainvoke
input_ = await coro_with_context(part(), context, create_task=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5454, in ainvoke
return await self.bound.ainvoke(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 405, in ainvoke
llm_result = await self.agenerate_prompt(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 1017, in agenerate_prompt
return await self.agenerate(
^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 975, in agenerate
raise exceptions[0]
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 1134, in _agenerate_with_cache
async for chunk in self._astream(messages, stop=stop, **kwargs):
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_anthropic/chat_models.py", line 1442, in _astream
_handle_anthropic_bad_request(e)
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_anthropic/chat_models.py", line 1422, in _astream
stream = await self._acreate(payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/langchain_anthropic/chat_models.py", line 1368, in _acreate
return await self._async_client.beta.messages.create(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/anthropic/resources/beta/messages/messages.py", line 2430, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/anthropic/_base_client.py", line 1898, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigateway/app/venv/ai-gateway-M6hW6iiC-py3.12/lib/python3.12/site-packages/anthropic/_base_client.py", line 1698, in request
raise self._make_status_error_from_response(err.response) from None
anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "messages.1.content.0: Input tag 'reasoning' found using 'type' does not match any of the expected tags: 'document', 'image', 'redacted_thinking', 'search_result', 'server_tool_use', 'text', 'thinking', 'tool_result', 'tool_use', 'web_search_tool_result'"}, 'request_id': 'req_011CUb3xNyghQuQCRtyCYy8A'}
Edited by Sebastian Rehm