Skip to content

A request keeps its newest pictures; older ones go as their words - #269

Merged
lydakis merged 25 commits into
mainfrom
claude/project-thread-ebs9s5
Oct 28, 2026
Merged

lydakis merged 25 commits into
mainfrom
claude/project-thread-ebs9s5

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

This follows up on #242, from Codex's last finding there (George chose to merge #242 first and do this next).

Each message may carry 20 pictures, but nothing bounded a whole request. Anthropic takes at most 100 pictures and 32 MB in a request, so a long conversation with many screenshots could stop getting replies until it compacted. Now a request keeps its newest pictures, and older ones go as their words.

How

This reuses elision, the mechanism that already sends answered tool results as stubs below a floor.

  • A prompt with pictures gets a stub. The stub is the prompt's words plus a line: [20 picture(s) sent with this message, elided from this request]. It's stored beside the node, like a result's stub, and counted with the pictures at their weight.
  • A result's picture stub is made for any saving. It used to need to save 1 KiB, so a small picture could never be left out.
  • Each node records how many pictures it has in a new nodes.pictures column (schema 58, with a migration). The window counts them, leaving out those that go as stubs.
  • Before a call, if the window sends more than 100 pictures, or more than 20 MiB of picture bytes beyond weight, the elision floor moves until at most 50 pictures and 10 MiB remain. Those are the newest. Halving means the floor moves seldom, so the cached prefix holds. As with any elision, only what the model has already answered goes. This applies to every bot, with or without read, because a picture's stub names no tool.
  • A compaction's pinned prompt goes as its stub when it is below the floor, and turn_usage and the compaction check count it that way.

Ordinary elision at the compaction threshold now also stubs older prompts that carry pictures, as it does results. A full-size picture weighs 6,400 bytes, so that's room it gives back.

The same limits apply to every provider. OpenAI's are larger, so this only bites on Anthropic in practice.

Testing

  • New tests:
    • Store: a_request_keeps_its_newest_pictures_and_older_ones_go_as_their_words. Six prompts of 20 pictures each make 120. Planning for 50 keeps the newest two turns, and the oldest prompt goes as its words. A byte bound keeps only the newest turn. Each window streams exactly the bytes it counts.
    • Store: a_pinned_prompt_under_the_floor_counts_as_its_stub (fails without the fix: 2527 vs 1153 bytes).
    • pictures_count_at_their_weight_and_go_whole now also checks that an elided prompt goes as its words.
    • tests/test_images.py: test_a_request_keeps_its_newest_pictures_and_older_ones_go_as_their_words. Six turns of 20 pictures each, through a real daemon: the sixth request sends pictures for only the newest two prompts.
  • cargo test --workspace passes, except three task tests that need fusermount3, which this machine lacks. The full runtime suite passes (506 tests). CI is green.
  • Matched perf screen against main in docs/DAEMON_MEASUREMENTS.md ("Request picture limits"): every difference is inside run-to-run range.

🤖 Generated with Claude Code

claude added 19 commits October 27, 2026 23:03
… messages

- A markdown link's underlined text is now a link too, not just the
  address drawn after it in brackets. Paths of files that exist (relative
  to the agent's folder, absolute, or under ~/, with :LINE or #L after
  them) open as file:// links.
- Ctrl-H (0x08) deletes like Backspace, in the composer and pickers.
- Each staged queued or steered message has a blank row above it, as in
  the history, and the last one a blank row before the status row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
…s in the daemon

Sonny attaches a picture from the clipboard on Ctrl-V, or an image file
whose path is pasted or dropped on the terminal, behind an [Image #N]
placeholder; PNGs are scaled to 1568px on their longest side. The
daemon's submit takes `images` (base64 PNG, JPEG, GIF or WebP), checks
them, keeps them with the turn, and sends them after the words in each
provider family's own shape. `agent run --image PATH` sends one from the
CLI. History reads leave the picture bytes out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
Ctrl-Y puts back what Ctrl-W, Ctrl-U, Ctrl-K or a word deletion took;
Alt-D and Ctrl/Alt-Delete delete the next word; Ctrl-J and Alt-Enter start
a new line; Ctrl-P/N move a row; Ctrl-Alt-H deletes a word. Ctrl-Y and
Ctrl-N no longer answer a pending approval as `y` and `n` do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
…tores them once

Ctrl-C (or Esc in a side chat) drops the pictures with the text. A
/side question sends the pictures its placeholders name. Once a prompt
is a node its pictures live there; the turn keeps their SHA-256, which
a retry is checked against. History pages and reads leave pictures out
in a subquery whose cheap guard spares items without any.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
A PNG, JPEG, GIF or WebP file comes back as a line naming it and the
picture, in each family's result shape. One longer than 1568 px on a side
is scaled down, and one over 1 MiB re-encoded as a JPEG. Other binary
files stay refused. History reads leave a result's picture bytes out, as
they do a prompt's, and elision stubs a picture result as its text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
A picture counted by its base64 bytes, so a few large ones filled the
context budget, brought compaction early, and made the pacer estimate
a 1 MiB picture at ~350,000 tokens, which a pool with a learned limit
refused before sending.

Each picture now weighs four bytes per estimated token (width × height
/ 750 once the longest side fits 1568, at most 1600). Nodes record
what their pictures add beyond that weight (`pictured`, schema 55),
and `total_bytes` leaves it out, so every window, compaction and
elision budget sees the weight with no change to its query. Only a
request's length adds the bytes back: the window and compaction plans
carry `pictured` per item for the Content-Length and read-ahead, and
`Items.weight` is what the pacer estimates from.

A picture result's stub saves what the result weighs over it, so only
a large picture is elided.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
…mall ones at full cost

- `read` scales a picture in a blocking worker, one at a time, so the
  daemon's one thread keeps serving every other bot meanwhile.
- A picture that must be scaled and has more than 64 megapixels is
  `image_limit`, refused from its header before decoding, and decoding
  is capped at 256 MiB besides: a small PNG can claim 12000 × 12000.
- A picture that compresses to less than its token cost counts at its
  cost: `pictured` may be negative, so a blank 1568 × 1568 PNG of a few
  KB weighs its 1600 tokens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
An absorption batch now reads a steer's pictures only while they fit an
8 MiB budget past its first steer's, and leaves the rest for the next
batch. Sonny refuses a picture past 5 MB once scaled, PNG too, and one
that would bring a message's pictures past 5 MB together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
# Conflicts:
#	src/store/db.rs
…heir words

Anthropic takes 100 pictures and 32 MB in a request, and a long
conversation can hold more. A prompt that came with pictures now gets a
stub, its words and a line on the pictures, and a result's picture stub is
made for any saving. Each node records how many pictures it has (schema
58), and the window counts them. Before a call, past 100 pictures or 20 MiB
of their bytes beyond weight, the elision floor moves for any bot until at
most 50 and 10 MiB remain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDNh4a2FzyND7nayar
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T06:17:50.050160Z 936aa0d New commits
🔒 Security Review ✅ Completed 2026-10-28T06:19:44.177253Z 936aa0d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d17523e588

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
Comment thread src/store/db.rs Resolved

lydakis commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Full Rust suite passes here except the three SandFS task tests that need fusermount3; the Python runtime suite passes (506 tests; the lookout tests that failed on a stale binary pass on a fresh build).


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: ce015a7687

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@lydakis
lydakis merged commit 08ae84b into main Oct 28, 2026
3 checks passed
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.

2 participants