Repository navigation
Every ending says which model the request was for - #81
Merged
Merged
Conversation
`request_finished`, `request_failed` and `request_cancelled` now carry `model`, the same string `request_started` has. A listener is not always there when a request starts. The desktop app subscribes while its window is open, and the overview's live chart only while the overview is showing, and usage arrives with the ending. With the model only on the start event, a request that began before anyone was listening and ended while someone was had its tokens and cost land on no model: the live chart drew them as "Unknown model", a layer of their own, whenever the overview was opened mid-task. `Ending` takes the model when it is created and hands it to whichever ending happens, including the one reported from `Drop`. WebSocket sessions send an empty string, as their start event does, because the upgrade request names no model. The recorder already has the model from the start event and ignores the new field. The endings integration tests check the model on every path, and on the WebSocket path that it is empty rather than made up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn
force-pushed
the
feat/end-events-carry-the-model
branch
from
September 21, 2026 12:52
2285f66 to
a07630e
Compare
Merged
fylorn
added a commit
that referenced
this pull request
Sep 21, 2026
`request_finished`, `request_failed` and `request_cancelled` now carry `model` (#81), so a listener that joins mid-request still knows which model an ending's usage belongs to. Additive; CONTROL_API_VERSION unchanged. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
request_finished,request_failedandrequest_cancellednow carrymodel, the same stringrequest_startedhas.Why
A listener is not always there when a request starts. The desktop app subscribes while its window is open, and the overview's live chart only while the overview is showing, and usage arrives with the ending. With the model only on the start event, a request that began before anyone was listening and ended while someone was had its tokens and cost land on no model. The desktop app's live chart drew them as "Unknown model", a layer of their own, whenever the overview was opened in the middle of a task.
What changed
tw-api:model: String(#[serde(default)]) on the three end events, next toid.tw-gateway:Ending::newtakes the model; each ending (finished, failed, cancelled, and the ones reported fromDrop) hands it on. HTTP requests pass the model from the request body; WebSocket sessions pass an empty string, as their start event does, because the upgrade request names no model.tw-store: the recorder already has the model from the start event, so its match arms ignore the new field.A field-only addition to the protocol, so the next tag is a patch.
Tests
ending.rs: a new unit test checks that all three endings carry the model, and the panic path is checked too.tests/endings.rs: every HTTP scenario now also checks the ending's model against the one in the request body (finished, cancelled mid-stream, cancelled before headers, failed mid-stream, refused by every upstream, phase-two deny). On the WebSocket path it checks the model is empty rather than made up.cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspacepass locally. Twooauthtests only pass withHTTP_PROXYunset, because a local proxy answers the deliberately unreachable address with a 503. That's this machine, not the change.🤖 Generated with Claude Code