Skip to content

fix: read /status token usage from SQLite session stats#13404

Closed
wbsch52 wants to merge 1 commit into
NousResearch:mainfrom
wbsch52:fix/status-token-usage-from-sqlite
Closed

fix: read /status token usage from SQLite session stats#13404
wbsch52 wants to merge 1 commit into
NousResearch:mainfrom
wbsch52:fix/status-token-usage-from-sqlite

Conversation

@wbsch52

@wbsch52 wbsch52 commented Apr 21, 2026

Copy link
Copy Markdown

Summary

  • make gateway /status read token totals from the SQLite session record first
  • keep the legacy in-memory session entry as a fallback when no DB row exists
  • add a regression test covering the SQLite-backed token display path

Root cause

Gateway token accounting is now persisted directly into state.db, but /status still displayed session_store JSON metadata. That JSON path no longer updates token totals, so /status could show 0 even when the session had real usage recorded in SQLite.

Testing

  • source venv/bin/activate && pytest tests/gateway/test_status_command.py -q
  • source venv/bin/activate && pytest tests/gateway/test_status_command.py tests/gateway/test_unknown_command.py -q

@mxnstrexgl

Copy link
Copy Markdown

🤖 Automated PR Review\n\n### Security Scan\n- ✓ No hardcoded secrets found\n- ✓ No SQL injection vectors\n- ✓ No path traversal risks\n- ✓ No unsafe deserialization\n- ✓ No command injection\n\n### Code Quality\n- ✓ Clean implementation\n- ✓ Tests included/updated\n- ✓ No code duplication detected\n\n### Summary\n✓ Automated review complete. No concerns detected.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13820 — same root cause: /status reading stale SessionStore instead of SQLite SessionDB for token totals.

@wbsch52 wbsch52 closed this by deleting the head repository Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants