Skip to content

Provide cost estimates before strict USD budget admission #57

Description

@4nass

Context

The hard budget gate now supports USD ceilings (max_run_cost_usd, max_stage_cost_usd, max_window_cost_usd). In strict and local_fallback modes, a provider call is intentionally refused when no pre-call cost estimate is available. This is fail-safe: an unknown cost must not be treated as free.

Problem

Providers such as subscription-based Claude Code and Codex CLI generally report cost only after the call. As a result, a strict USD budget can block every call even when the configured ceiling has ample remaining capacity.

Expected outcome

Add a documented, safe pre-call estimation strategy: provider/model pricing metadata with versioned rates; token-based cost estimation using the existing reservation estimate; or an explicit per-call USD reserve in the budget class. Define behavior when pricing metadata is stale or unavailable.

The estimate must remain part of the reservation and be reconciled with the provider-reported cost after the call. Unknown costs must continue to fail closed in strict modes unless the user explicitly selects a documented fallback policy.

Acceptance criteria

  • Strict USD budgets can admit a call when a verifiable estimate fits the remaining ceiling.
  • Concurrent reservations include the estimated USD amount.
  • Settlement replaces the estimate with actual provider cost and rejects overruns deterministically.
  • Pricing source, currency, freshness, and fallback behavior are visible in reports/telemetry.
  • Soft, strict, and local_fallback semantics remain covered by regression tests.

Related: #45, PR #56.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions