claude-code - 💡(How to fix) Fix Resumed sessions with many images fail with unrecoverable dimension error [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45543Fetched 2026-04-09 08:02:56
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Error Message

When a session accumulates many images (e.g. screenshots pasted during a long coding thread) and is later resumed via the SDK's resume option, the API rejects the request with a 400 error about image dimensions exceeding the limit for many-image requests. The SDK catches this error but surfaces it as the model's response text with no recovery path - particularly in non-interactive (SDK) mode where the only suggestion is "Start a new session with fewer images." I wrote a workaround that detects this error, strips the oldest image from the session JSONL, and retries. It peels one image per attempt until the API accepts. This confirms the session is otherwise valid - only the bulk image submission is the problem.

Fix Action

Fix / Workaround

Workaround:

I wrote a workaround that detects this error, strips the oldest image from the session JSONL, and retries. It peels one image per attempt until the API accepts. This confirms the session is otherwise valid - only the bulk image submission is the problem.

RAW_BUFFERClick to expand / collapse

When a session accumulates many images (e.g. screenshots pasted during a long coding thread) and is later resumed via the SDK's resume option, the API rejects the request with a 400 error about image dimensions exceeding the limit for many-image requests. The SDK catches this error but surfaces it as the model's response text with no recovery path - particularly in non-interactive (SDK) mode where the only suggestion is "Start a new session with fewer images."

Reproduction:

  1. Run a session via the SDK (query() with resume: sessionId)
  2. Over the course of the session, accumulate 20+ images in the conversation (screenshots, tool outputs, etc.)
  3. Let the session idle until it's evicted
  4. Send a new message to trigger a resume

The resume fails with:

An image in the conversation exceeds the dimension limit for many-image requests (2000px). Start a new session with fewer images.

Why it works live but fails on resume:

During a live session, the same images are accepted by the API on every turn. On resume, the entire conversation is reconstructed from the JSONL and sent to the API in one shot. The API applies a stricter per-image dimension limit (2000px) in the "many-image" regime. The images are individually under 2000px (e.g. 850x1100), but sending them all at once triggers the rejection that never happened during incremental turn-by-turn ingestion.

Expected behavior:

The SDK already has the full message history in the JSONL. On resume, it could replay the conversation incrementally - feeding messages to the API one by one the same way they were originally ingested. If the API accepted each turn during the live session, it should accept the same sequence during restore. This would avoid the many-image regime entirely.

Workaround:

I wrote a workaround that detects this error, strips the oldest image from the session JSONL, and retries. It peels one image per attempt until the API accepts. This confirms the session is otherwise valid - only the bulk image submission is the problem.

extent analysis

TL;DR

Modify the SDK to replay the conversation incrementally during resume, feeding messages to the API one by one, to avoid triggering the stricter per-image dimension limit for many-image requests.

Guidance

  • Identify the point at which the SDK reconstructs the conversation from the JSONL and sends it to the API in one shot during resume.
  • Modify the SDK to iterate through the JSONL and send messages to the API incrementally, mimicking the original turn-by-turn ingestion.
  • Implement a check to ensure that the API accepts each turn during the replay, and handle any errors that may occur.
  • Consider incorporating the provided workaround as a fallback, which strips the oldest image from the session JSONL and retries, to ensure session validity.

Example

# Pseudocode example of incremental replay
def resume_session(session_id):
    jsonl = load_jsonl(session_id)
    for message in jsonl:
        # Send message to API incrementally
        response = api.send_message(message)
        if response.error:
            # Handle error, potentially using the workaround
            handle_error(response.error)

Notes

The provided workaround confirms that the session is otherwise valid, and only the bulk image submission is the problem. However, this approach may not be suitable for all scenarios, and a more robust solution would be to modify the SDK to replay the conversation incrementally.

Recommendation

Apply the workaround, as it provides a functional solution to the issue, although it may not be the most efficient or scalable approach. A more permanent fix would involve modifying the SDK to replay the conversation incrementally, which would require further development and testing.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING