Skip to content

Python: [Bug]: Anthropic pause_turn is mapped to stop and ends hosted-search work prematurely #9479

Closed

Description

@coding-totoro

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.1

Run 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.0
  • agent-framework-anthropic==1.0.0b261015
  • anthropic==1.11.0
  • httpx2==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.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 18, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Oct 18, 2026
  3. github-actions commented on Oct 18, 2026

    @github-actions
    Contributor

    🤖 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, where pause_turn is mapped to stop and consumed by both response-processing paths. It triggers when Anthropic pauses hosted server-tool work, causing agent.run() to return after one request. Minimal repro: use a mock Anthropic transport that returns pause_turn first and end_turn second, then assert that the agent makes two requests and returns the second response.

    • Failing test: python/packages/anthropic/tests/test_anthropic_client.py::test_agent_continues_anthropic_pause_turn
    • Files examined: python/packages/anthropic/agent_framework_anthropic/_chat_client.py, python/packages/anthropic/tests/test_anthropic_client.py, python/packages/anthropic/pyproject.toml
    • Tests run: packages/anthropic/tests/test_anthropic_client.py, test_agent_continues_anthropic_pause_turn
    • Reported version: 1.0b261015
    • Current version: 1.0.0b261015
  4. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 18, 2026
  5. eavanvalkenburg commented on Oct 27, 2026

    @eavanvalkenburg
    Member

    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.

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

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions