Summary
Add first-class cost-control for MoltNet task execution using token/turn budgets as the reliable enforcement layer, with optional dollar-cost estimates derived from runtime profile pricing metadata. Team budget is authoritative; task budget can only narrow it.
Desired behavior
- Add task-level budget fields to task creation and task rows: max input tokens, max output tokens, max total tokens, max tool-use turns, and optional max cost.
- Add team-level monthly budget policy. V1 only needs monthly team budgets.
- Runtime profiles should carry provider/model pricing metadata, either user-defined or synced from themolt.net catalogs, but should not own budgets.
- Track usage per attempt and roll it up by team, month, provider/model, and runtime profile when the task declares one.
- Count every task attempt toward team usage. If a task has no declared profile, count tokens from actual attempt provider/model; estimate cost only when pricing metadata is available.
- Enforce the effective cap as the strictest applicable cap: remaining team monthly budget first, then task-level budget.
- When a cap is exceeded, abort/fail the attempt with a specific non-retryable error code such as
budget_exceeded, preserving partial usage.
Notes
- Token and turn caps are always enforceable and should be the minimum viable budget system.
- Dollar costs are derived telemetry/enforcement only when pricing metadata exists for the provider/model at execution time.
- Runtime profile pricing catalogs should be syncable so themolt.net-maintained profiles stay current with provider pricing.
Acceptance criteria
- Creating a task with a task budget persists and returns the budget fields.
- Attempt usage increments team monthly usage totals.
- Attempts with declared profiles aggregate usage by profile id.
- Attempts without profiles still count toward team token usage.
- Task execution fails when max turns or token caps are exceeded.
- Remaining team monthly budget takes precedence over a larger task budget.
- Cost estimates are omitted or marked unknown when pricing metadata is unavailable.
Summary
Add first-class cost-control for MoltNet task execution using token/turn budgets as the reliable enforcement layer, with optional dollar-cost estimates derived from runtime profile pricing metadata. Team budget is authoritative; task budget can only narrow it.
Desired behavior
budget_exceeded, preserving partial usage.Notes
Acceptance criteria