Repository navigation
Python: [Bug]: Anthropic pause_turn is mapped to stop and ends hosted-search work prematurely #9479
Description
Observed Behavior
The Python Anthropic integration maps pause_turn to stop. An agent using hosted web search therefore treats unfinished server-side work as a completed turn, without issuing a continuation request.
This was also observed with a real streamed web-search response. The offline repro below isolates the behavior without credentials, network access, application code, or custom middleware.
Expected Behavior
The agent should continue the paused server turn with the returned assistant content and the same tools, or at minimum preserve pause_turn so an application can distinguish it from normal completion. It should not silently report successful completion.
Anthropic documents that pause_turn requires resending the paused content to continue the server-side work: server tools and pause_turn.
Steps to Reproduce
Install:
pip install agent-framework-core==1.22.0 agent-framework-anthropic==1.0.0b261015 anthropic==1.11.0 httpx2==2.13.1Run the following standalone script. The mock transport returns pause_turn first and a completed response if a second request is made.
Minimal Reproduction
import asyncio
import json
import httpx2 as httpx
from anthropic import AsyncAnthropic
from agent_framework.anthropic import AnthropicClient
async def main():
requests = []
def transport(request):
requests.append(json.loads(request.content))
first = len(requests) == 1
return httpx.Response(200, json={
"id": f"msg_{len(requests)}",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-6",
"content": [{"type": "text", "text": "Still researching." if first else "Finished."}],
"stop_reason": "pause_turn" if first else "end_turn",
"stop_sequence": None,
"usage": {"input_tokens": 10, "output_tokens": 2},
})
async with httpx.AsyncClient(transport=httpx.MockTransport(transport)) as http:
async with AsyncAnthropic(api_key="unused-offline-test", http_client=http) as raw:
client = AnthropicClient(anthropic_client=raw, model="claude-sonnet-4-6")
async with client.as_agent(
tools=[client.get_web_search_tool()],
default_options={"max_tokens": 512},
) as agent:
result = await agent.run("Research this topic.")
print(f"requests={len(requests)}, finish_reason={result.finish_reason}, text={result.text!r}")
asyncio.run(main())Actual Output
requests=1, finish_reason=stop, text='Still researching.'
No exception is raised. The prepared second response is never requested.
Environment
agent-framework-core==1.22.0agent-framework-anthropic==1.0.0b261015anthropic==1.11.0httpx2==2.13.1- Python 3.14.7, macOS
- Regression: unknown
Additional Context
FINISH_REASON_MAP explicitly contains "pause_turn": "stop" (source).
This is distinct from #9478, which concerns hosted-search block serialization when mixed with local tool calls. This repro has no local function tools. #7849 addressed unmapped finish reasons; pause_turn is already mapped, but to normal completion.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Oct 18, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
The bug occurs in
python/packages/anthropic/agent_framework_anthropic/_chat_client.py::_map_finish_reason, wherepause_turnis mapped tostopand consumed by both response-processing paths. It triggers when Anthropic pauses hosted server-tool work, causingagent.run()to return after one request. Minimal repro: use a mock Anthropic transport that returnspause_turnfirst andend_turnsecond, then assert that the agent makes two requests and returns the second response.python/packages/anthropic/tests/test_anthropic_client.py::test_agent_continues_anthropic_pause_turn1.0b2610151.0.0b261015eavanvalkenburg commentedon Oct 27, 2026
Thanks for the report. I will fold a fix for this into #9718, alongside the Anthropic server-tool replay work. We will track the implementation there rather than start a separate PR.