Skip to content

.NET: Python: [Bug]: A failed model call right after a tool runs leaves the session unusable ("No tool output found for function call") #10172

Closed

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:

  1. The model returns a function_call and the tool executes.
  2. The next model call, the one that would carry the tool's result, fails (HTTP 429 in our case).
  3. The persisted history now holds the function_call but no function_call_output for it.
  4. 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

  1. 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).
  2. Run a prompt that makes the model call the tool. The tool executes.
  3. Make the next model request fail. The repro answers it with HTTP 429 through an httpx.MockTransport.
  4. 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

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.

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 7, 2026
  2. changed the title [-]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")[/+] on Nov 7, 2026
  3. added
    agentsUsage: [Issues, PRs], Target: Single agent
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Nov 7, 2026
  4. github-actions commented on Nov 7, 2026

    @github-actions
    Contributor

    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 contained function_call call_1 with no function_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

    Generated by Issue Routing for #10172 · copilot · auto · ~21 AIC · ⌖ ~1 AIC · ⊞ 5.2K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowtriageUsage: [Issues], Target: All issues that still need to be triaged

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions