Skip to content

fix(session): only the read tool's image payload becomes an image - #460

Merged
mrnasil merged 2 commits into
mainfrom
fix/image-marker-anchor
Nov 24, 2026
Merged

mrnasil merged 2 commits into
mainfrom
fix/image-marker-anchor

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 24, 2026

Copy link
Copy Markdown
Member

Problem

split_whycodes_image_payload matched WHYCODES_IMAGE_B64: anywhere in a tool result. Reading a file that mentions the marker (e.g. crates/session/src/session.rs), or grepping for it, turned the text into an image_url part:

{"type":"image_url","image_url":{"url":"data:\";;base64,202 sy1l|fn spill_body(..."}}

scripts/bench_tokens.py hits this on its first read: 3,512 tokens of outline went out as an invalid data URL, which real providers reject.

Fix

The payload is only recognised in the exact shape the read tool emits: the marker opens a line, names an image/ type, and is followed only by base64. Anything else stays text.

Checks

  • cargo test -p whycodes-session --lib session:: (new cases: mid-line mention, non-image type, empty subtype, non-base64 body, marker on a later line)
  • fmt, clippy (session), panic / swallowed-error / dependency / secrets ratchets
  • bench_tokens.py on a release build: request 2 now carries the outline as plain text; totals unchanged within 0.1%

🤖 Generated with Claude Code

mrnasil and others added 2 commits November 24, 2026 19:03
split_whycodes_image_payload matched the WHYCODES_IMAGE_B64: marker
anywhere in a tool result. Reading a file that mentions it (session.rs
itself), or grepping for it, sent the text as an image_url part with a
data:";;base64,<source text> URL, which providers reject.

The marker must now open a line, name an image/ type, and be followed
only by base64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit beb6e14 into main Nov 24, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/image-marker-anchor branch November 24, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant