microsoft / microsoft/agent-framework

Python: Ensure we skip sending ErrorResponses to LLMs

Open
#2,986 1 comment 0 reactions 1 assignee View on GitHub

@giles17 is already working on this.

Since Aug 19, 2026.

hosting python question
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

If an LLM returns an error response, we save the error content in the entity state. When another request is made, these messages appear to be included in the request context. However, the LLM doesn't appear to accept error content; we may need to ensure it's stripped out for subsequent requests.

[2025-12-19T19:20:35.390Z] Traceback (most recent call last):
[2025-12-19T19:20:35.390Z]   File "/Users/phoff/Source/microsoft/agent-framework/python/packages/core/agent_framework/openai/_chat_client.py", line 76, in _inner_get_response
[2025-12-19T19:20:35.390Z]     await client.chat.completions.create(stream=False, **options_dict), chat_options
[2025-12-19T19:20:35.390Z]   File "/Users/phoff/Source/microsoft/agent-framework/python/.venv/lib/python3.10/site-packages/openai/resources/chat/completions/completions.py", line 2672, in create
[2025-12-19T19:20:35.390Z]     return await self._post(
[2025-12-19T19:20:35.390Z]   File "/Users/phoff/Source/microsoft/agent-framework/python/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1794, in post
[2025-12-19T19:20:35.390Z]     return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
[2025-12-19T19:20:35.390Z]   File "/Users/phoff/Source/microsoft/agent-framework/python/.venv/lib/python3.10/site-packages/openai/_base_client.py", line 1594, in request
[2025-12-19T19:20:35.390Z]     raise self._make_status_error_from_response(err.response) from None
[2025-12-19T19:20:35.390Z] openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid value: 'error'. Supported values are: 'text', 'image_url', 'input_audio', 'refusal', 'audio', and 'file'.", 'type': 'invalid_request_error', 'param': 'messages[8].content[0].type', 'code': 'invalid_value'}} 

We do have logic to skip the ErrorContent from the messages to LLM. There might be a bug there I guess -

 # Build messages from conversation history, excluding error responses
            # Error responses are kept in history for tracking but not sent to the agent
            chat_messages: list[ChatMessage] = [
                m.to_chat_message()
                for entry in self.state.data.conversation_history
                if not self._is_error_response(entry)
                for m in entry.messages
            ]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.