Repository navigation
feat(finops): add provider cost arbitrage and budget governance - #1047
Merged
AmitoVrito merged 9 commits intoSep 22, 2026
Merged
Conversation
DhruvGarg111
force-pushed
the
feat/issue-893-cost-governance
branch
from
September 17, 2026 13:16
1e179b8 to
6d9ec5d
Compare
DhruvGarg111
force-pushed
the
feat/issue-893-cost-governance
branch
from
September 17, 2026 13:17
6d9ec5d to
10ef007
Compare
…et cap bypass record_spend() wrote spend under the raw (unstringified) tenant_id/api_key_id while every budget check reads via str(tenant_id)/str(api_key_id), so a non-string identifier silently bypassed the cap indefinitely. Co-authored-by: Dhruv Garg <[email protected]>
_stream_generate only re-raised BudgetExceededError after exhausting every candidate; any other exception (network error, provider outage) silently ended the generator with zero tokens, unlike generate()/call() which always raise. Restores symmetry so stream() callers can distinguish a genuinely empty response from total candidate failure. Co-authored-by: Dhruv Garg <[email protected]>
…erage BudgetLedger.commit() re-validates actual cost against the cap at settlement time, which could previously raise BudgetExceededError after the provider call already succeeded — discarding a response the caller already paid for. commit() now accepts force=True to record real spend without re-checking the cap, and CostQualityRouter uses it as a fallback: log the overage and still return/stream the response. The pre-call reserve()/check_before() cap enforcement is unchanged. Co-authored-by: Dhruv Garg <[email protected]>
The original CostQualityRouter implementation was renamed to _LegacyCostQualityRouter when the new finops-aware router was added, but nothing in src/ or tests/ ever referenced it. Co-authored-by: Dhruv Garg <[email protected]>
…dition Once a tenant/API-key budget is configured, routing to a model missing from the pricing table now hard-fails instead of silently costing $0 — call this out as a precondition so custom/self-hosted models get their pricing registered up front. Co-authored-by: Dhruv Garg <[email protected]>
…overnance # Conflicts: # README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #893.
CostQualityRouterwith quality/latency-aware arbitrage, provider-aware pricing, tenant/API-key budgets, atomic reservations and settlement caps, spend attribution, fallback-chain composition, and optional carbon accounting.synapsekit_budget_remaining_usdandsynapsekit_arbitrage_savings_usdPrometheus gauges.Commits
feat(finops): add provider pricing and budget governancefeat(observability): add FinOps spend gaugestest(ci): add cost arbitrage benchmark gateVerification
$0.036000vs$0.750000) with equal quality (0.920vs0.920).git diff --checkpassed.tests/agents/test_tools.py::TestPythonREPLTool::test_timeout_on_slow_operation.No provider SDK or network service is required by the benchmark.