Agent SDK query() timeout on initialize — regression in 2.1.90

Resolved 💬 3 comments Opened Apr 3, 2026 by ederson16 Closed Apr 6, 2026

Description

claude_agent_sdk.query() fails with Control request timeout: initialize when using Claude Code CLI version 2.1.90. The same code works correctly with version 2.1.81.

Environment

  • OS: Ubuntu 24.04 (Docker container, python:3.12-slim)
  • Claude Code CLI: 2.1.90 (broken) / 2.1.81 (works)
  • claude-agent-sdk: 0.1.54
  • Node.js: 22.x
  • Python: 3.12

Steps to Reproduce

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

async def test():
    opts = ClaudeAgentOptions(
        model="claude-sonnet-4-20250514",
        cli_path="/usr/bin/claude",
        max_turns=1,
        permission_mode="acceptEdits",
    )
    async for msg in query(prompt="say hello", options=opts):
        if isinstance(msg, ResultMessage):
            print("OK:", msg.result)
            return

asyncio.run(test())

Expected Behavior

Query initializes and returns a response (works on 2.1.81).

Actual Behavior

Timeout after ~60s with:

Exception: Control request timeout: initialize
  File "claude_agent_sdk/_internal/query.py", line 407, in _send_control_request
asyncio.exceptions.CancelledError: Cancelled via cancel scope; reason: deadline exceeded
  File "claude_agent_sdk/_internal/query.py", line 406, in _send_control_request
    with anyio.fail_after(timeout):
TimeoutError

Notes

  • claude -p "say hello" via CLI works fine on both versions — only the SDK query() path is affected
  • Two containers with identical auth/credentials: one with 2.1.81 (works), one with 2.1.90 (fails)
  • Workaround: pin @anthropic-ai/claude-code@2.1.81 in Dockerfile

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗