claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Long requests to the SDK onerous/unworkable in shell orchestration

Open adamavenir opened this issue 6 months ago • 2 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
  • Claude CLI version: 1.0.16 (Claude Code)
  • Operating System: macOS 15.4
  • Terminal: all

Bug Description

I've been atempting to orchestrate commands that use Claude SDK and repeatedly run into issues with more complex asks timing out.

Steps to Reproduce

Attempt 1:

❯❯❯ claude -p "I'm testing the handling of timeouts when running the claude code cli. I need your help. I'd like you to write a massive treatise on the history of quantum computing and the implications it has for both the future of computing and science in general. Maximize your output so I can test long-running prompts."

API Error: Request timed out.

Attempt 2 got a response but... not much of one

claude -p "I'm testing the handling of timeouts when running the claude code cli. I need your help. I'd like you to write a massive treatise on the history of quantum computing and the implications it has for both the future of computing and science in general. Maximize your output so I can test long-running prompts."

I'll write an extensive treatise on quantum computing for your timeout testing purposes. Let me create a comprehensive document with maximum detail.

As a control, here's a very simple request that worked fine:

❯❯❯ claude -p "Can you write me a 12 line poem about API timeouts?"

Here's a 12-line poem about API timeouts:

The spinner turns, the seconds crawl,
A promise hangs in digital space.
The server sleeps behind its wall,
While patience fades without a trace.

"Request timeout" — the dreaded phrase,
That breaks the flow of data streams.
Connection lost in network maze,
Shattering our coding dreams.

Retry logic kicks in fast,
Exponential backoff waits.
But sometimes servers breathe their last,
And 504 seals our fates.

Expected Behavior

  • Actual output I'd expect from Claude

Actual Behavior

In one case:

API Error: Request timed out.

Just the start of a response in the other case.

adamavenir avatar Jun 06 '25 19:06 adamavenir

Try running with --output-format "stream-json" --verbose to follow along with what tool is timing out. For increasing the time out of any individual tool try taking a look at this:

https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables

However I have seen some having issues configuring this for bash (example https://github.com/anthropics/claude-code/issues/1717)

michael-hedgineer avatar Jun 06 '25 20:06 michael-hedgineer

the problem is "env": { "MAX_THINKING_TOKENS": "32000" } , remove it

furkancak1r avatar Jun 19 '25 07:06 furkancak1r

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Oct 10 '25 10:10 github-actions[bot]

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] avatar Dec 10 '25 10:12 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Dec 17 '25 14:12 github-actions[bot]