microsoft / microsoft/agent-framework
Python: [Bug]: Foundry Hosting - User messages added to conversation chat history for failed requests
@TaoChenOSU is already working on this.
Since Aug 13, 2026.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
### Description
If a user sends a message to a hosted agent that the agent cannot process while using a conversation, the input messages will be saved to the chat history for that conversation. This means that the every subsequent request using that conversation will fail, because the "bad" message will now be stored in the conversation's chat history.
### Code Sample
First, deploy a hosted agent to Foundry (also occurs when running locally)
```py
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
endpoint = "https://.services.ai.azure.com/api/projects/"
agent_name = ""
with (
DefaultAzureCredential() as credential,
AIProjectClient(endpoint=endpoint, credential=credential) as project_client,
):
client = project_client.get_openai_client(agent_name=agent_name)
conversation = client.conversations.create()
response = client.responses.create(
input=[
{
"role": "user",
"content": "Hello, how are you?",
},
{
"type": "function_call_output",
"call_id": "call_12345abc",
"output": "example function call output",
},
],
conversation=conversation.id,
)
if response.error:
print(f"Error: {response.error}")
else:
print(f"Output: {response.output_text}")
response2 = client.responses.create(
input="Hello, how are you?",
conversation=conversation.id,
)
if response2.error:
print(f"Error: {response2.error}")
else:
print(f"Output: {response2.output_text}")
```
```console
Error: ResponseError(code='server_error', message='(" service failed to complete the prompt: Error code: 400 - {\'error\': {\'message\': \'No tool call found for function call output with call_id call_12345abc.\', \'type\': \'invalid_request_error\', \'param\': \'input\', \'code\': None}}", BadRequestError("Error code: 400 - {\'error\': {\'message\': \'No tool call found for function call output with call_id call_12345abc.\', \'type\': \'invalid_request_error\', \'param\': \'input\', \'code\': None}}"))')
Error: ResponseError(code='server_error', message='(" service failed to complete the prompt: Error code: 400 - {\'error\': {\'message\': \'No tool call found for function call output with call_id call_12345abc.\', \'type\': \'invalid_request_error\', \'param\': \'input\', \'code\': None}}", BadRequestError("Error code: 400 - {\'error\': {\'message\': \'No tool call found for function call output with call_id call_12345abc.\', \'type\': \'invalid_request_error\', \'param\': \'input\', \'code\': None}}"))')
```
* The first request fails, as expected, as this is a new conversation and there is no assistant tool call with ID `call_12345abc` in the conversation
* However, the second request, which is valid, should succeed, however it doesn't because the input messages from the first request are now saved to the conversation.
While this is a contrived example, it shows that input messages should not be saved to a conversation unless the request was successful, otherwise the conversation cannot be used again. This is the case when using the Azure OpenAI.
### Error Messages / Stack Traces
```markdown
```
### Package Versions
agent-framework-core: 1.13.0, agent-framework-foundry: 1.10.4, agent-framework-foundry-hosting: 1.0.0b260730, agent-framework-openai: 1.12.0
### Python Version
3.13.14
### Additional Context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.