Skip to content

Fix quota learning re-anchors and stale session checks - #16

Merged
merefield merged 1 commit into
mainfrom
agent/quota-learning-reanchors
Aug 15, 2026
Merged

merefield merged 1 commit into
mainfrom
agent/quota-learning-reanchors

Conversation

@merefield

Copy link
Copy Markdown
Owner

Why

API-EQ learning could unexpectedly fall from accumulated clean movement to zero when the backend revised a future rolling-window reset timestamp or when shared-daemon model resolution retroactively changed accounting counters. Separately, a quiet overnight child rollout could contribute CHECK SESSION to an otherwise freshly active grouped root.

What changed

  • keep the earliest observed reset boundary and re-anchor only on a validated reset or discontinuity
  • retain a responsive RESTARTED reason whenever learning legitimately returns to zero
  • keep daemon model-resolution calls pending outside finalized priced and unpriced totals
  • defer quota observations while accounting is pending or changes across the quota request
  • suppress only inferred CHECK SESSION when any member of the grouped root has fresh activity or an exact working daemon status
  • continue propagating definite INPUT NEEDED and APPROVAL NEEDED from linked agents
  • document the estimator and attention behavior
  • bump the maintained source version to v0.7.4

Verification

  • go test -race -cover ./...
  • go vet ./...
  • gofmt -l .
  • go build -trimpath ./...
  • rebuilt and format-checked macOS, Linux, and Windows binaries for amd64 and arm64
  • verified the local binary reports codexometer v0.7.4

Regression coverage includes reset-time revisions, true reset boundaries, accounting rebases, pending reroute accounting, long inactivity without quota movement, and an overnight grouped child whose root resumes activity.

@merefield
merefield marked this pull request as ready for review August 15, 2026 09:01
@merefield
merefield requested a lite review from Copilot August 15, 2026 09:01

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 tightens Codexometer’s quota-learning and session-attention behavior to avoid false “learning reset” events and stale CHECK SESSION signals in grouped sessions, while also making local API-EQ accounting monotonic when daemon model resolution is pending.

Changes:

  • Refines API-EQ quota learning to preserve clean movement across reset-time revisions, re-anchor only on validated discontinuities/resets, and surface persistent RESTARTED: ... reasons instead of silently dropping to 0/5PP.
  • Separates pending daemon model-resolution calls from finalized priced/unpriced totals and defers quota observations while accounting is pending or changes during the quota request bracket.
  • Suppresses inferred CHECK SESSION at the grouped-root level when any linked agent shows fresh activity or an exact “working” daemon status; updates docs and bumps version to v0.7.4.

Reviewed changes

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

Show a summary per file
File Description
README.md Documents the updated estimator semantics, attention suppression rules, and bumps the documented version to v0.7.4.
main_test.go Updates version expectations and includes pending-call equality in demo accounting comparisons.
internal/version/version.go Bumps maintained fallback source version to 0.7.4.
internal/version/version_test.go Updates fallback version test to expect 0.7.4.
internal/ui/quota_api_eq.go Implements re-anchoring/restart-reason logic, preserves earliest reset boundaries, and includes pending-call counters in observation stability.
internal/ui/quota_api_eq_test.go Adds coverage for reset-time revisions/inactivity, boundary passing, accounting rebases, and pending-call deferral behavior.
internal/ui/model.go Defers quota observations when pending accounting exists (even if counters are stable).
internal/ui/model_test.go Adds test ensuring pending-call presence forces observation deferral.
internal/codex/live_usage.go Tracks pending daemon model resolutions separately, finalizes accounting monotonicly, and improves grouped CHECK SESSION suppression based on fresh activity/exact working status.
internal/codex/live_usage_test.go Adds tests for grouped attention suppression and pending daemon reroute accounting behavior.

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

@merefield
merefield merged commit 0ad95d0 into main Aug 15, 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