Repository navigation
Description
Observed Behavior
With per-service-call history persistence (require_per_service_call_history_persistence=True, which create_harness_agent sets for every harness agent), this sequence leaves a session that can no longer run:
- The model returns a function_call and the tool executes.
- The next model call, the one that would carry the tool's result, fails (HTTP 429 in our case).
- The persisted history now holds the function_call but no function_call_output for it.
- Every later run on the session sends that unanswered call, and the Responses API rejects it: 400 - No tool output found for function call <call_id>.
The session only recovers if the application edits its history. By then the tool's side effect has already happened: I first hit this in a real run, when the deployment was throttled right after an approved restart_device call had executed.
Expected Behavior
A failed model call should not make the session unusable. For example:
- the tool's result is persisted as soon as it exists, so a resumed run sends the call together with its result, or
- a run that starts from a persisted function_call without a result settles it with a terminal result that says the outcome is unknown (the tool may or may not have completed), so the model can check before acting again.
Either way, the persisted history would keep the invariant from the function-loop spec (docs/specs/004-python-function-calling-loop.md) that every actionable local function_call has exactly one terminal function_result.
Steps to Reproduce
- Build an Agent with one tool, an InMemoryHistoryProvider, require_per_service_call_history_persistence=True and store=False (or use create_harness_agent, which sets the flag).
- Run a prompt that makes the model call the tool. The tool executes.
- Make the next model request fail. The repro answers it with HTTP 429 through an httpx.MockTransport.
- Run again on the same session. The request contains the function_call without a function_call_output, which a real Responses endpoint rejects with 400.
Minimal Reproduction
Runs offline with no credentials: a mock transport plays the Responses API and accepts the last request, so you can see what was sent.
pip install agent-framework-core agent-framework-openai (no credentials needed: a mock transport plays the Responses API)
import asyncio
import json
import httpx
from openai import AsyncOpenAI
from agent_framework import Agent, InMemoryHistoryProvider, tool
from agent_framework.openai import OpenAIChatClient
sent = [] # request bodies, in order
tool(approval_mode="never_require")
def restart_device(device_id: str) -> str:
"""Restart a field device."""
print(f"tool executed: restart_device({device_id!r})")
return f"{device_id} restarted"
def response(n: int, item: dict) -> dict:
return {"id": f"resp_{n}", "object": "response", "created_at": 0, "status": "completed", "model": "mock",
"output": [item], "parallel_tool_calls": True, "tool_choice": "auto", "tools": [],
"usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2,
"input_tokens_details": {"cached_tokens": 0}, "output_tokens_details": {"reasoning_tokens": 0}}}
def handler(request: httpx.Request) -> httpx.Response:
sent.append(json.loads(request.content))
n = len(sent)
if n == 1: # the model asks for the tool
return httpx.Response(200, json=response(n, {"type": "function_call", "id": "fc_1", "call_id": "call_1", "status": "completed",
"name": "restart_device", "arguments": '{"device_id": "INV-02"}'}))
if n == 2: # the request that carries the tool's result is throttled
return httpx.Response(429, json={"error": {"message": "Rate limit exceeded", "type": "rate_limit"}})
return httpx.Response(200, json=response(n, {"type": "message", "id": f"msg_{n}", "role": "assistant", "status": "completed",
"content": [{"type": "output_text", "text": "Done.", "annotations": []}]}))
async def main() -> None:
openai_client = AsyncOpenAI(base_url="http://mock/v1/", api_key="unused", max_retries=0,
http_client=httpx.AsyncClient(transport=httpx.MockTransport(handler)))
agent = Agent(
client=OpenAIChatClient(model="mock", async_client=openai_client),
tools=[restart_device],
context_providers=[InMemoryHistoryProvider()],
require_per_service_call_history_persistence=True, # create_harness_agent sets this for every harness agent
default_options={"store": False},
)
session = agent.create_session()
try:
await agent.run("Restart device INV-02.", session=session)
except Exception as e:
print(f"run 1 failed: {type(e).__name__}")
await agent.run("Continue.", session=session) # the mock accepts it; the real Responses API returns 400
items = sent[-1]["input"]
answered = {i["call_id"] for i in items if i.get("type") == "function_call_output"}
print("function_call sent without a function_call_output:",
[i["call_id"] for i in items if i.get("type") == "function_call" and i["call_id"] not in answered])
asyncio.run(main())
Output with agent-framework-core 1.24.0 and agent-framework-openai 1.18.0:
tool executed: restart_device('INV-02')
run 1 failed: ChatClientException
function_call sent without a function_call_output: ['call_1']
Against a real Responses endpoint, that last request fails with the 400 below. A live drill of the full scenario is recovery_drill.py in https://github.com/mcekikj/nightshift-ms-harness.
Error Messages and Stack Traces
Live, Azure OpenAI Responses API (v1) on a Microsoft Foundry resource, same sequence with the 429 injected on the second request:
ChatClientException: ("<class 'agent_framework_openai._chat_client.OpenAIChatClient'> service failed to complete the prompt: Error code: 400 - No tool output found for function call call_KCNZ6XlvTO7Kk3cG5E2vIPf4.", BadRequestError(...))
First seen with FoundryChatClient after real throttling, then on every retry:
ChatClientException: ("<class 'agent_framework_foundry._chat_client.FoundryChatClient'> service failed to complete the prompt: Model deployment rate limit exceeded. ...")
ChatClientException: ("<class 'agent_framework_foundry._chat_client.FoundryChatClient'> service failed to complete the prompt: Error code: 400 - No tool output found for function call call_oY7VTrjMjStptodiydQl6QVR.", BadRequestError(...))
Package Versions
agent-framework-core 1.24.0, agent-framework-openai 1.18.0, agent-framework-foundry 1.16.0 (the minimal repro also fails on agent-framework-core 1.12.0 and 1.13.0)
Python Version
3.12.13
Operating System
macOS
Regression
No
Additional Context
- Live check on 7 November 2026: the resumed run fails with the same 400 with store=False and with store=True.
- With per-service-call persistence off (the Agent default), the failed run persists nothing. The session stays usable, but the tool call that did execute disappears from the transcript.
- Related: .NET: Foundry Hosting resilient recovery of a non-workflow agent fails with "No tool output found for function call" when the crash lands between a tool call and its result #9033 is the same seam in .NET Foundry hosting resilient recovery (fix in progress in .NET: Keep resilient tool-call snapshots consistent #9080). Python: fix empty local shell calls leaving orphaned history #9803 fixed the empty local shell call case only.
- Prior art in the framework: dangling calls are already settled after a MiddlewareFailure on service-managed conversations, and AG-UI recovers an interrupted occurrence "as indeterminate when no idempotency key proves retry safety".
- My workaround: after a failed run, insert a placeholder function_result after each unanswered call that says the outcome is unknown and asks the model to check state with read-only tools before repeating the action (heal_dangling_tool_calls, https://github.com/mcekikj/nightshift-ms-harness/blob/main/nightshift/approvals.py#L130-L197). In all four live drill runs, the unrepaired resume was rejected with this error, and the repaired session finished the shift correctly.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Python: [Bug]: A failed model call right after a tool runs leaves the session unusable ("No tool output found for function call")[/-][+].NET: Python: [Bug]: A failed model call right after a tool runs leaves the session unusable ("No tool output found for function call")[/+]github-actions commentedon Nov 7, 2026
Reproduced on the Python base checkout (
924a6e5) with an independently written offline mock-transport test. The tool ran and the next model call returned 429. Run 1 failed, and the resumed request on the same session containedfunction_callcall_1with nofunction_call_output. I did not test against a live Responses endpoint, so the 400 itself is not observed here.Support boundary: direct support. This is core Python history persistence with
require_per_service_call_history_persistence=True. The reporter cites the function-calling loop spec (docs/specs/004-python-function-calling-loop.md) as the source of the invariant. I did not verify the exact spec wording. The report has been routed to the Python core owner. Priority and scope are for maintainers to decide.Evidence: https://github.com/microsoft/agent-framework/actions/runs/42423716190