Skip to content

tools: bench_image_session plays one image chat session and records cached tokens and first-token time - #1889

Merged
ashhart merged 2 commits into
mainfrom
lead/k5-image-session
Nov 2, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/k5-image-session

Conversation

@ashhart

@ashhart ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

A small client for one image chat session, for #1828's check and similar ones: does a server keep and resume an image turn's prompt across a session, and do the replies stay the same?

What it does

tools/bench_image_session.py --base-url URL --image PNG plays one chat of --turns turns (10 by default) against an OpenAI-compatible /v1/chat/completions. Every turn resends the same picture in the first user message, keeps the whole history, and adds one short new question. For each turn it records:

  • the reply's sha256 and completion tokens;
  • cached prompt tokens (usage.prompt_tokens_details.cached_tokens, or null if not reported);
  • first-token time, from a streamed request.

--out FILE writes one JSON line per turn, then a summary line. Arguments are checked with tools/bench_args.py. Defaults: temperature 0, 64 max tokens.

Checks

tools/tests/test_bench_image_session.py runs a stdlib loopback server with no GPU or network. It checks that the history grows, the image is sent every turn, and every field is recorded, and that bad arguments are refused. Both tests pass.

No engine code changes.

Every turn resends the same PNG, keeps the history and adds a question.
Each line records the reply sha256, usage counters and first-token time;
the last line summarizes the session. A loopback test checks the history,
the image and the fields.

Refs #1828
…d records cached tokens and first-token time
@ashhart
ashhart force-pushed the lead/k5-image-session branch from 6762607 to 69c10bb Compare November 2, 2026 06:22
@ashhart
ashhart merged commit 088cfbd into main Nov 2, 2026
0 of 13 checks passed
@ashhart
ashhart deleted the lead/k5-image-session branch November 10, 2026 16:34
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