Record token usage per turn and show daily, weekly and all-time totals by host

This commit is contained in:
Gmer4Lfe
2026-08-04 18:04:46 -04:00
parent 961c57c6f0
commit 969a85f303
8 changed files with 340 additions and 3 deletions
+17
View File
@@ -1644,6 +1644,23 @@
AI_MEMORY_FILE="$DATA_DIR/ai_memory.md"
AI_MEMORY_MAX_CHARS=4000 # ~1000 tokens — truncated with a notice if exceeded
# ━━━ AI Token Accounting ━━━
# One row per completed turn, appended by whichever path ran it — the WebGUI worker and the
# ai_query.sh CLI both write here, so the totals are not silently the tab's alone. Format is
# pipe-delimited to match the other data/*.db files:
#
# date|time|host|profile|source|prompt_tokens|completion_tokens|tok_s
#
# The host column records where the turn ran, not where it is read. Each host keeps its own
# data/ and nothing syncs it, so a host only ever sees its own rows — the column is there so
# the file is already shaped right if the partner payload fetch is ever extended to carry it.
# A column added later cannot be backfilled.
#
# Retention is by row count rather than age: pruning is considered only when the file passes a
# size threshold, so an ordinary turn costs one stat() and an append.
AI_TOKEN_DB="$DATA_DIR/ai_token_history.db"
AI_TOKEN_RETAIN_ROWS=20000 # oldest rows dropped past this — years of ordinary use
# ━━━ AI Feature Toggles ━━━
# Tier 1 is narration — it cannot change a decision. Tier 2 adds context to a decision a script
# already made. Tier 3 assists a human. Enable in that order, and give each one weeks.