Repository navigation
feat(serve): model, effort, context window and name in the session status, with a snapshot while a turn runs - #974
Merged
Merged
Conversation
…atus, with a snapshot while a turn runs (#573) GET /sessions/{id}/status gains model, effort, contextWindow, contextUsed, name, snapshotAt and stale, read by the same code as tole status. While a turn runs the route answers from the last-known snapshot without taking the turn lock.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
GET /sessions/{id}/statusgainsmodel,effort,contextWindow,contextUsed,name,snapshotAtandstale. While a turn runs it answers from the last-known snapshot (stale: true) instead of going blank, and never waits for the turn lock.Closes #573.
Why
A remote client's footer (
model · effort · context used / window · name) had no route to read these, and the route returnednullfor everything exactly while the user watched a turn run (#527, #528, #529 are blocked on this).Changes
session/status.rs:StatusSnapshot(thetole statussnapshot plus the session name and a timestamp),StatusCell(last snapshot plus a per-model detected window),take_snapshot(pure, no network),detect_window. The window is the configured one (TOLE_CONTEXT_WINDOW/ config, same astole status) or what the provider's/modelsreported for the session's model.session/host.rs:SessionState.status(a small separate lock),refresh_status,last_status,warm_status. The snapshot is refreshed at session open, when a turn (or approval resume) settles, and when a register changes.serve.rs: the status route reads live when the storage is free and refreshes the snapshot; when a turn holds it, it returns the snapshot withstale: true.with_idle_sessionrefreshes after model/effort/name/compact writes. The/modelswindow lookup runs on a background thread after open and after a turn, never on the request path.entriesandusage_reportstaynullduring a turn).stale(bool) plussnapshotAt(epoch ms);staleis true exactly when the snapshot is served instead of a live read;effortis the session register only (astole status), not the process default;contextUsedis the last prompt's tokens (0 before the first call);nameis the register, else the creation alias.docs/mobile-control.md(field table),docs/desktop-design.md,CHANGELOG.md.Testing
serve_status_fields_equal_tole_status(compares the route with the realtole statusoutput for the same session),serve_status_answers_from_a_snapshot_while_a_turn_runs(mock provider holds a turn at a gate; three polls answer under 2 s withbusy,stale, the snapshot values; live again after the turn), plus unit tests for null unknowns (no window detected, no snapshot) and the per-model window cache.cargo fmt --all;cargo clippy -D warningson the workspace,--no-default-features, and--no-default-features --features shell-tools: clean.cargo test -p tole-cli: 1632 passed, 0 failed (includesface_parity, 2 passed).scripts/review-local.shnot run here.