Skip to main content

kiro-fix-session-images

Repair Kiro CLI sessions that stopped working with this error:

At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels

A screenshot larger than 2000px (usually a Retina capture) gets stored in the session history, so every later request that replays it fails. This tool scans each session's transcript, downscales every embedded image above the limit to 1900px on its longest side, and rewrites the file in place. The original is kept next to it with .bak added to its name.

Warning: Close the session in Kiro before running, then resume it.

Install

With uv (recommended):

uv tool install kiro-fix-session-images

Or run it once without installing:

uvx kiro-fix-session-images --all --dry-run

Or with pip:

pip install kiro-fix-session-images

Quick start: fix a broken session

Works for Kiro CLI and Kiro IDE sessions, in both on-disk layouts: ~/.kiro/sessions/<hash>/<id>/messages.jsonl and the flat ~/.kiro/sessions/cli/<id>.jsonl. A session's sub-agent transcripts (sub-executions/) are repaired along with it.

1. Exit the broken session. In Kiro CLI type /exit; in Kiro IDE close the chat tab. Kiro must not be writing to the session file while it is repaired.

2. Pick the session and fix it. cd into the project directory and run:

cd /path/to/your/project
uvx kiro-fix-session-images

A list of this directory's sessions opens (every directory's, if this one has none), newest first, each marked ok or N oversized. Type to filter (title, id or workspace), use the arrow keys to move, and press Enter to fix the highlighted session. Tab switches to sessions from every directory; Esc quits without changing anything.

Prefer to fix everything at once? uvx kiro-fix-session-images --all.

3. Resume the session.

kiro-cli chat --resume                  # Kiro CLI: most recent session here
kiro-cli chat --resume-id sess_<id>     # Kiro CLI: a specific session

In Kiro IDE, reopen it from the session history list.

If the session still fails, put the original back by copying the .bak file over the transcript. Where that is depends on the layout:

# directory layout (Kiro CLI and IDE)
cd ~/.kiro/sessions/<hash>/<id>
cp messages.jsonl.bak messages.jsonl
cp sub-executions/<uuid>.jsonl.bak sub-executions/<uuid>.jsonl   # if one was repaired

# flat layout
cd ~/.kiro/sessions/cli
cp <id>.jsonl.bak <id>.jsonl

Sub-agent transcripts that the flat layout links through parent_session_id in <id>.json are listed and repaired as sessions of their own, not with their parent.

Usage

# Pick a session from a list (run inside the project directory)
kiro-fix-session-images

# List sessions for this directory with their IDs and status, then exit
kiro-fix-session-images --list
kiro-fix-session-images --list --title deploy   # match title, id or workspace
kiro-fix-session-images --list --all            # every directory

# Fix one session by ID (CLI sess_<id> or the bare IDE id both work)
kiro-fix-session-images sess_<id>

# The sess_ prefix is added automatically if you omit it
kiro-fix-session-images <id>

# Fix every session
kiro-fix-session-images --all

# Report what would change without touching any file
kiro-fix-session-images --all --dry-run

# Use a smaller target size (default 1900, must be below 2000)
kiro-fix-session-images --all --max 1600

# Scan a different sessions directory (default ~/.kiro/sessions)
kiro-fix-session-images --all --root /path/to/sessions

Each affected session is printed as <id>: resized X/Y images, followed by a done: N oversized image(s) fixed summary. A repaired sub-agent transcript is printed under its session as <id> (sub-execution <uuid>): resized X/Y images. With --dry-run the wording changes to would resize and found.

How resizing works

Images are resized with Pillow, which is installed as a dependency, and saved back in their original format (PNG, JPEG, GIF or WEBP) with their EXIF metadata and color profile intact. Animated GIF and WEBP keep every frame.

If an image can't be read, that image is skipped and reported as N unreadable. The other images in the session are still fixed, the rest of the run continues, and the exit status is 1. --dry-run reports and exits the same way, so it tells you in advance what the real run cannot repair.

Platforms

macOS, Linux and Windows. Requires Python 3.9 or newer.

License

MIT

Metadata

Release files for kiro-fix-session-images 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kiro-fix-session-images 0.4.1
File Size Uploaded
kiro_fix_session_images-0.4.1.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kiro-fix-session-images 0.4.1
File Interpreter ABI Platform
kiro_fix_session_images-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.7 kB

Release files / kiro_fix_session_images-0.4.1.tar.gz

Download URL kiro_fix_session_images-0.4.1.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
438529cb54910bcdce5cca258f94be4cc53f729b9e14bc534e667df0f79109d0
BLAKE2b-256 checksum
How to use checksums
795f16ce1e8f406ca0ddbcdb541cf856f1c34985bcc06c948ae9545a0cf44533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / kiro_fix_session_images-0.4.1-py3-none-any.whl

Download URL kiro_fix_session_images-0.4.1-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46d7807ba5cc3fa441c5a88a97f078a02b5c33a058050bf4ca89b5060819bdf1
BLAKE2b-256 checksum
How to use checksums
6b130f83b19808e7423aa107f0006ff6a641a319698b9dd21379840b7cb6132c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page