fix(agents): virtual-provider budget cost is priced against the agent-level (provider, model), not the selected backend #159
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveractors-core#159
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Metadata
fix(agents): attribute virtual-provider cost to the selected backendfix/virtual-provider-cost-attributionBackground and context
ADR-2038 virtual-provider pooling lets each
backendsentry overrideprovider/model(spec §4.4.7), and each backend is constructed and credential-validated independently. The in-run budget machinery, however, anchors on the agent's own attributes:LLMAgent._accumulate_cost_after_invoke(agents/llm.py) resolves rates via_compute_cost(current_pricing, self.provider, self.model, …), and the #150 zero-cost carve-out in_check_budget_before_invokeconsults the same pair via_is_zero_rated_invocation(current_pricing, str(self.provider), str(self.model)). For a pooled agent those agent-level values are inheritance defaults, not the backend that actually served the invocation.Current behavior
Verified from the platform side during the cleverthis-webapp#549 E2E oneshot (2026-10-27, cleveractors @
4b98ce00; platform semantics per #473:max_cost_usdis always set from the payer's wallet balance):deepseek/deepseek-v4.1-flash+zai/glm-5.3-flashand agent-level anchorzai/glm-5.1: runs succeed, but accumulated cost is computed at the anchor model's rates — the rates of the backend that actually served never enter the gate, so cost accounting for pooled agents is wrong whenever backends differ from the agent-level pair.(provider, model)is absent from the pricing table while the backends themselves are priced,_accumulate_cost_after_invokeraisesExecutionError(kind="cost", reason="missing_pricing_entry")after a successful model call — the run fails even though the invoked backend has valid pricing. With #473's always-set limit there is no configuration that avoids this short of adding the anchor model to the pricing table._check_budget_before_invoke's zero-cost carve-out consults the agent-level pair: a provably-free backend cannot pass the gate when the agent-level pair is unresolvable or non-zero-rated ("anything unresolvable still blocks").Expected behavior
Cost attribution for virtual-provider invocations should use the selected backend's provider/model —
VirtualChatModelknows which backend served each call, so per-call token counts can carry that attribution back toLLMAgent. The agent-level pair remains the fallback for non-virtual agents. At minimum, an unpriced agent-level pair must not fail runs whose actually-selected backends are priced.Acceptance criteria
missing_pricing_entry.nox -s typecheck,nox -s unit_tests, and the coverage threshold stay green.Supporting information
max_cost_usd), #150/#151 (zero-cost carve-out precedent, "anything unresolvable still blocks").VirtualChatModel(response metadata or a selection callback) soLLMAgentcan attribute cost; alternatively accept a per-backend pricing-resolution hook from the platform.Subtasks
_accumulate_cost_after_invokeand_check_budget_before_invoke.docs/index.md§4.4.7, ADR-2038 cost note, and CHANGELOG; revisitbenchmarks/virtual_provider_benchmark.pyif the hot path changes.Definition of Done