Claude Agent SDK Python 0.2.160 fixes follow-up turns dying with 'Stream closed' after a background subagent finishes
GitHub·medium signal
The bug hit query() calls that use hooks, can_use_tool or SDK MCP servers. When a subagent finished just before the turn's result arrived, the SDK closed stdin too early and the model reported the tool as refused. The SDK now waits for the CLI to report idle through session_state_changed, capped by CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS (default 10 minutes). TypeScript SDK 0.3.283, released the same day, now emits warnings as `system/informational` messages instead of dropping them.