Repository navigation
Conversation
The runner priced calls and selected timeouts and refusal policies from the individual delegation alone. Shared limits could therefore count no cost or answer with the wrong policy.
This branch has not been deployed
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.
What this does
delegation_budgetaccepts every budget key, and the docs andBudgetcomments show it withrates:, butDelegation::Runnerread only the agent-wide budget's limits. Everything else came from the delegation's own budget:rates:set agent-wide priced nothing:Pricing.cost_forgotbudget.rates(the delegation's, usuallynil), so with no registered price the agent-widemax_costnever fired.timeout:set agent-wide was never enforced;with_timeoutusedbudget.timeoutonly.on_exceeded: :raiseset agent-wide was ignored. A call refused at a shared limit, a timeout, and a delegated pause for input all followedbudget.policy, which is:stopunless the delegation sets its own.On
main, withdelegation_budget max_cost: 0.5, rates: { input: 1_000_000, output: 1_000_000 }, every delegation records a cost of0.0and keeps running; withdelegation_budget max_calls: 1, on_exceeded: :raisethe second call returns{ error: "budget_exceeded" }instead of raising.The runner now:
rates, or the agent-wide ones when it has none, and records that cost on both ledgers;on_exceeded, or the agent-wide policy when it sets none, for refusals, timeouts and paused sub-agents.docs/actions/delegation.mdsays so under Budgets.Decision for the maintainer
A delegation's own
on_exceededandrateswin over the agent-wide ones, even when the limit that tripped is agent-wide, the same waydelegate_to ..., budget:already overrides the callee's contract budget. The alternative is to take the policy from whichever budget was violated. That changes nothing for the common case (only one of them sets a policy), and I'm glad to switch if you prefer it.Tests
test/features/delegation_test.rbandtest/features/input_requests_test.rb:max_cost;:raise;:raise;:raise;ratesandon_exceededstill override the agent-wide ones (this one passes before the change too; it guards the precedence).The first five fail on
mainand pass with the change.Type of change
Scope check
Related issue
Fixes #749
Quality check
bin/rubocopon the changed files)gemfiles/rails8.gemfile: 4732 runs, 0 failures, 11 errors, 66 skips. The 11 errors are all inactionagent/test/cli_contract_test.rband are the same on unmodifiedmainin my environment (NoMethodError: undefined methodid' for an instance of Hashin rack-session under WebMock'sto_rack`), so they are unrelated to this change)docs/actions/delegation.md, CHANGELOG entry)Ownership
API changes
Behavior change to note: an app that set
delegation_budget on_exceeded: :raiseortimeout:and relied on them doing nothing will now see them apply.