Per-bot spending limits and alerts
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend-api-design
Direzione di ricerca
Start by reading docs/guide/llm-call-ledger.md and crates/agent-core/src/usage.rs, then trace how max_tokens_per_turn is enforced in crates/agent-core. The issue requires agreeing on budget units, periods, scope, unknown usage, stop behavior, and concurrency before implementation; done means an agreed design and the listed backend, alert, UI, localization, schema, and test criteria are met.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
size: L · first-timer: no
Please comment before starting so we can agree on the design. What counts as "spend", and what happens when the limit is hit, need to be decided first.
Summary
Add per-bot spending limits and alerts: an optional daily or monthly cap on a bot's model usage (cost where known, tokens otherwise) with a warning threshold, a clear stop behaviour, and visible meters in the app.
Why it matters
Always-on bots and schedules can burn through an API budget while nobody is watching. Users already see what was spent after the fact; they have no way to say "this bot may spend at most this much a month". That is a prerequisite for trusting a bot with unattended work.
Current state
- Every model call is recorded in the LLM call ledger with a purpose, tokens and optional
cost_usd(crates/agent-core/src/usage.rs,docs/guide/llm-call-ledger.md).GET /v1/usageaggregates by bot and purpose; the UI shows it inapps/desktop/ui/src/views/UsageView.tsx. - Limits exist only per turn:
guards.max_tokens_per_turnincrates/agent-core/src/config.rs, and a subagent gets a quarter of what its parent has left (crates/agent-core/src/subagent.rs). There is no per-bot, per-day or per-month limit and no alerting. - Cost can be unknown: tokens may be missing (failed calls, embeddings), CLI engines expose one session invocation rather than token counts, and prices come from the current provider catalog entries (
with_catalog_pricesincrates/agent-core/src/shared.rs, overridable throughLoopConfig::prices). The ledger doc is explicit that unknown tokens do not mean zero. - Bot profiles are TOML/JSON profiles with sections such as
[router]and[runtime](docs/guide/bots-and-profiles.md).
Proposal and suggested approach
Settle these in a design note first:
- the unit (money vs. tokens vs. calls) and how unknown costs are handled so a limit cannot be bypassed by missing data;
- the period and timezone (rolling 24 h/30 d or calendar day/month);
- scope (per bot, global, or both) and what includes subagents, scheduled runs and background memory work;
- the stop behaviour: refuse new runs, stop the current run at the next model call, or ask the user once to continue;
- concurrency (two runs reading the same remaining budget).
Then implement in slices:
- A
[budget]section in the bot profile (and an optional global default) with validation and tests. - A budget check in the agent loop before each model dispatch, reading from the ledger; the failure is a typed, human-readable error code (add it to the human-error layer in both locales).
- Events and alerts: a warning at a configurable threshold and a hard-stop event; show them as a banner/toast and send them to Telegram if configured.
- UI: a meter per bot in the usage view and the bot panel, and fields in the bot editor.
- Tests with a fake provider that reports usage, including unknown-usage calls and concurrent runs.
Follow the migration rules in CONTRIBUTING.md if storage changes (numbered, forward-only, check open pull requests for the number).
Acceptance criteria
- Design note agreed in this issue.
- A bot with a tiny limit stops with a clear message instead of silently continuing; a bot without a limit behaves exactly as before.
- Unknown-cost calls are handled according to the agreed rule and covered by tests.
- Usage UI shows remaining budget;
check:i18n, lint, typecheck,cargo test -p agent-core -p daemon-apipass; OpenAPI snapshot and generated schema updated.
Out of scope
Billing integrations, real-time provider balance lookups, per-chat limits, changing prices or the catalog.
How to get started
Read docs/guide/llm-call-ledger.md and crates/agent-core/src/usage.rs, then look at how max_tokens_per_turn is enforced in crates/agent-core. Comment here with your proposed answers to the design questions.
- Lingua principale
- Rust
- Stelle
- 0
- Fork
- 1
- Merge medio
- 6h 54m
- PR unite (30g)
- 152
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di emreocell/Praxi-Bot
-
area: desktop-ui enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Add an LLM provider presetApertaarea: daemon enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Contribute example skillsApertadocumentation enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
emreocell/Praxi-Bot#168 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di emreocell/Praxi-Bot
Issue simili
-
bug ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
userFRM/egui-charts#3363 ·
I maintainer di solito rispondono entro 1 giorno
-
ada documentation mobile report
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
physicsdolphin/nv-uefi-unlocker#254 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
kindraywind/rustnarok-client#1382 ·
I maintainer di solito rispondono entro 1 giorno
-
area:accessibility bug good first issue help wanted priority:p3-low size:small
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NecturaLabs/Canopy#209 ·
-
CLI config custom-model enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno