Skip to content

Resolve live shared-daemon model reroutes - #15

Merged
merefield merged 2 commits into
mainfrom
agent/shared-daemon-reroutes
Aug 14, 2026
Merged

merefield merged 2 commits into
mainfrom
agent/shared-daemon-reroutes

Conversation

@merefield

@merefield merefield commented Aug 14, 2026 •

Copy link
Copy Markdown
Owner

Why this change

Codexometer's rollout-only telemetry records the model a turn requested, but not transient server-side model reroutes. It also cannot always distinguish a session waiting for user input or approval from one still running a long local tool. That leaves two of its most useful readouts unnecessarily approximate: API-equivalent costing can be attributed to the wrong model, and Monitor may have to show the cautious CHECK SESSION fallback.

A shared Codex app-server already exposes the missing live, per-thread signals. This PR consumes those signals opportunistically, correlates them with the durable rollout without reading conversation content, and preserves the existing behavior whenever the optimized setup is unavailable.

Summary

  • keep a persistent connection to the managed Unix Codex app-server daemon
  • subscribe only to recently active threads that the daemon has already loaded
  • correlate model/rerouted and thread/tokenUsage/updated with rollout calls by thread, turn, cumulative checkpoint, and full response usage
  • price positively matched calls with the resolved model while retaining requested-model fallback everywhere else
  • preserve precise Monitor attention status and gracefully support absent, disconnected, or older daemons
  • add a benefit-led recommended Codex CLI setup guide and document the privacy and fallback boundaries
  • bump the maintained version to v0.7.3

Accounting safeguards

Subscribed calls wait at most one refresh for a matching reroute observation. A proven match uses the resolved model; no match falls back to the requested model. This avoids provisional repricing contaminating quota-learning samples.

Unknown models, new token fields, and unpriceable resolved usage continue to fail closed. The client ignores server requests and conversation content, asks thread/resume to exclude turns, and never loads unrelated historical threads.

Validation

  • go vet ./...
  • go test -race -cover ./...
  • local Linux build
  • cross-builds for macOS amd64/arm64, Linux amd64/arm64, and Windows amd64/arm64

Race-enabled coverage:

  • root: 67.9%
  • internal/codex: 84.8%
  • internal/ui: 91.2%
  • internal/version: 81.0%

@merefield
merefield marked this pull request as ready for review August 14, 2026 20:18
@merefield
merefield requested a lite review from Copilot August 14, 2026 20:18

Copilot AI 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.

Pull request overview

This PR improves Codexometer’s live telemetry accuracy by opportunistically consuming shared app-server daemon signals (without reading conversation content) to (a) disambiguate Monitor attention states and (b) correctly attribute API-equivalent pricing to server-rerouted models when an exact correlation can be proven, while preserving the existing requested-model and writer-lock fallbacks when the daemon is absent/disconnected/unsupported. It also bumps the maintained version to v0.7.3 and documents the recommended CLI/daemon setup and privacy boundaries.

Changes:

  • Add a persistent Unix app-server daemon connection with per-thread subscription, plus model-reroute + token-usage correlation to resolve rerouted models for pricing when positively matched.
  • Extend the rollout reader to track turn IDs and support one-refresh “pending” model resolution with a safe requested-model fallback.
  • Update docs and versioning/tests for the v0.7.3 release and the recommended daemon-backed CLI setup.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
README.md Reworks daemon guidance into a recommended setup section; documents resolved-model costing, privacy boundaries, and fallback behavior; bumps version references.
main_test.go Updates CLI --version output expectation to v0.7.3.
internal/version/version.go Bumps maintained source-build fallback version to 0.7.3.
internal/version/version_test.go Updates version test expectations to 0.7.3.
internal/codex/live_usage.go Adds turn-id tracking plus pending/resolved model reroute reconciliation that adjusts API-equivalent pricing when matched to daemon observations.
internal/codex/live_usage_test.go Adds tests covering delayed reroute correction, fail-closed behavior on unpriceable usage, and requested-model finalization when no reroute arrives.
internal/codex/daemon_status.go Expands the status provider contract to return runtime statuses plus resolved-model observations and subscription set.
internal/codex/daemon_status_unix.go Implements a persistent websocket client with subscriptions, reroute/usage event correlation, and snapshotting for the rollout reader.
internal/codex/daemon_status_unix_test.go Extends tests to cover loaded-thread-only subscription, reroute observation capture, and missing-socket fallback.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@merefield
merefield merged commit f42399e into main Aug 14, 2026
7 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