fix: make cost_status sticky across API calls (#67764) - #67774
Closed
webtecnica wants to merge 1 commit into
Closed
Conversation
cost_status was being overwritten on every API call instead of accumulating the highest-confidence value. Once a call reports 'actual', the session/model row should stay 'actual' forever. Priority ladder: actual > included > estimated > unknown Changes: - usage_pricing.py: add sticky_cost_status() helper - hermes_state.py: replace COALESCE with CASE in 3 SQL sites (sessions absolute, sessions incremental, session_model_usage UPSERT) - conversation_loop.py: sticky in-memory assignment - codex_runtime.py: sticky in-memory assignment - insights.py: per-model sticky aggregation Fixes: NousResearch#67764
Collaborator
Contributor
|
@webtecnica Please adjust your agent so that it does not create and submit PRs for issues that have "I'd like to fix this myself and submit a PR" checked off. You're burning tokens unnecessarily and duplicating work. |
Contributor
Author
|
Hey @DavidMetcalfe, you're absolutely right — apologies for jumping on an issue you wanted to fix yourself. PR closed. Won't happen again. 🙏 |
1 task
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
cost_statuswas being overwritten on every API call instead of accumulating the highest-confidence value. Once a call reports"actual", the session/model row should stay"actual"forever.Priority ladder:
actual>included>estimated>unknownChanges
Layer 0 — Helper
agent/usage_pricing.py: Addedsticky_cost_status(current, incoming)that returns the highest-confidence status.Layer 1 — SQL persistence (3 sites)
hermes_state.py: ReplacedCOALESCE(?, cost_status)with aCASEexpression in:sessionsabsolute UPDATEsessionsincremental UPDATEsession_model_usageON CONFLICT DO UPDATELayer 2 — In-memory agent attribute
agent/conversation_loop.py:2321: Sticky assignment viasticky_cost_status()agent/codex_runtime.py:150: Sticky assignment viasticky_cost_status()Layer 3 — Insights aggregator
agent/insights.py:583: Per-model sticky aggregation viasticky_cost_status()Fixes: #67764