Repository navigation
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)
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
endpoint = "https://<RESOURCE>.services.ai.azure.com/api/projects/<PROJECT>"
agent_name = "<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}")Error: ResponseError(code='server_error', message='("<class \'agent_framework_foundry._chat_client.FoundryChatClient\'> 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='("<class \'agent_framework_foundry._chat_client.FoundryChatClient\'> 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_12345abcin 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
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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
github-actions commentedon Aug 12, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
Repro: The orchestrator in azure.ai.agentserver.responses.hosting._orchestrator persists input items for ALL responses (including failed ones) via create_response, and InMemoryResponseProvider.get_history_item_ids (store/_memory.py:317-324) returns items from all non-deleted responses without checking status. The fix location is in _handle_inner_agent (packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py, around line 459's finally block) or in the orchestrator's terminal persistence logic — either skip persisting input_items when status is "failed", or filter them out in get_history_item_ids. Minimal repro: send a request with conversation_id where agent.run raises, then send a second request in the same conversation and observe that the failed input appears in history.
python/packages/foundry_hosting/tests/test_repro_7630.py1.0.0b2607301.0.0b260730moonbox3 commentedon Sep 9, 2026
This should be handled in Azure/azure-sdk-for-python#48929. Please do not open a PR in MAF. Leaving open to track the dependency work/fix.