feat(stove-api): expose estimate and operator controls

This commit is contained in:
anor
2026-11-26 20:22:55 +10:00
parent de624297ed
commit a98aa460d4
19 changed files with 1074 additions and 12 deletions
+7 -1
View File
@@ -27,9 +27,15 @@ def cleanup(*, now=None) -> dict:
"UPDATE stove_api_requests SET status=? WHERE status=? AND ts<?",
(stove_history.STATUS_NO_RESPONSE, stove_history.STATUS_OPENED,
stove_history.iso(now - stove_history.STALE_OPEN_SEC))).rowcount
with db._conn() as conn:
settled = conn.execute(
"UPDATE llm_usage SET input_tokens=0, cache_tokens=0, output_tokens=0, "
"cost_basis='unknown' WHERE path='api:stove-estimate' AND cost_basis='pending' "
"AND ts<?", (now - 600,)).rowcount
freed = _free_old_bodies(stove_history.iso(now - stove_history.BODY_KEEP_SEC))
total = _finish_caps()
return {"closed_stale": closed, "deleted_bodies": freed, "history_bytes": total}
return {"closed_stale": closed, "settled_ai": settled,
"deleted_bodies": freed, "history_bytes": total}
def _free_old_bodies(old: str) -> int: