You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[backend] Resolve AI budget ceilings from config, not hardcoded constants — env default → per-account override, read in reserve()/openBudget #474
No env var, no per-account column, no admin setting reads them. The per-tree defaults in delegation-budget.ts (DEFAULT_LIMITS: $5/tree, 50 delegations, depth 4) are likewise static (with a p95-derived per-user cost ceiling in openBudget, but nothing settable). The only existing platform-AI setting is PUT /v1/admin/settings/platform-ai, a boolean kill switch — not a number.
Scope
Introduce an effective-ceiling resolver: per-account override (persisted) → platform default (persisted/admin-set) → env var → the current constant as the hard fallback. Constants become the last-resort default, not the source of truth.
Read the resolved value in reserve() (both the money and token checks) and in openBudget — never the raw constant.
Storage: a account_budget_limits D1 table (user_id, token_ceiling, charged_micros_ceiling, per_tree_cost_micros, delegations, max_depth, updated_at) + a platform-default row. Migration.
Correct the refusal message in reserve() — it currently says usage-ages-out but implies no lever; once configurable it should point at the setting. (Also the agent-facing claim "contact support to raise it" is fiction today — remove that pathway from any prompt/guidance.)
Guardrails: clamp to a sane max so a user cannot set an unbounded ceiling; keep it a circuit breaker.
Why
Unblocks the UI (#UI) and MCP (#MCP) surfaces. Without a resolver they would each reach for the constant.
Activity
serge-ivo commentedon Aug 10, 2026
Part of epic #478.
feat(budget): GET/PUT /v1/budget/limits — account ceiling API + OpenA…
feat(apply): an application opens a spend pool and draws on it every …