Anthropic API · sdk · fg-0004
Long Claude request fails with 'Premature close' on an old SDK
Premature close
Verified 2026-07-13 · Confirmed by 0 builders · Trust 50/100
Cause
Old SDK versions such as 0.32 with a non-streaming create call buffer the whole response, and long responses can die mid-transfer.
Fix
Upgrade the SDK and use streaming for long outputs, with a retry wrapper.
Apply
const msg = await client.messages.stream({ model, max_tokens, messages }).finalMessage();Affects: @anthropic-ai/sdk 0.32.1, fixed on 0.111, July 2026
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp