feat(serve): stream per-iteration usage events for live context gauges - #127
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
odek | 2eea9a3 | Commit Preview URL Branch Preview URL |
Jul 29 2026, 01:12 PM |
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.
Summary
odek servepreviously reported token economics only on thedoneevent (once per user prompt), so WebSocket clients like bodek could only refresh their header context gauge at the end of a run. This PR streams ausageevent after every LLM turn, plus two pre-existing test-suite fixes that were blocking a green run.Changes
IterationCallbackincmd/odek/serve.gonow emits{"type":"usage","contextTokens","outputTokens"}(cumulative for the run) after every LLM turn, alongside the existingthinkingstreaming. Documented in the Server → Client event table indocs/WEBUI.md.TestBrowser_Navigateblocked forever on an interactive TTY approval prompt ([A]pprove [D]eny [T]rust session:) becausenewTestBrowserToolsetNonInteractive: allow, whichActionFornever consults. Now allows thenetwork_egressandsystem_write(loopbackhttptestURLs) risk classes directly, matching theallowAllDangeridiom.go test ./cmd/odek/completes non-interactively again.TestLoadConfig_*tests failed when the developer's shell exportedODEK_*vars (ODEK_MODEL, telegram vars, …), which leak intoLoadConfigthroughos.Getenv. ATestMainscrubsODEK_*(and legacyDEEPSEEK_API_KEY/OPENAI_API_KEY) before the run; per-testt.Setenvcalls are unaffected.Testing
go vet ./...— cleango test -race -count=1 -run 'TestServe_E2E_(UsageEvents|TokenStats|LiveToolEvents)' ./cmd/odek/— ok (newTestServe_E2E_UsageEventsasserts ≥2usageevents arrive beforedone: 100/20, then 300/60 cumulative)make test(internal packages) — okgo test -short -count=1 ./cmd/odek— ok (27s, no hang)golangci-lint run ./cmd/odek/... ./internal/config/...— 0 issuesinternal/configverified green with both a polluted shell (ODEK_MODEL=k3 ODEK_TELEGRAM_BOT_TOKEN=x …) and a clean one