Repository navigation
Conversation
A worker session is one Ticket in docs/dsh-super-agent.md, but the MCP
surface re-granted AGENTDESCENT_MAX_CALLS to every start: with the ceiling
at 1, two starts each ran one call and the Ticket billed two.
The server now counts the calls its earlier runs charged (calls plus
pending_calls, read from the store) against the ceiling, clamps a second
start to the remainder, reports call_limit.ticket {ceiling, spent,
remaining} when there is earlier spend, and refuses a start once the
Ticket's ceiling is spent, naming the variable and the arithmetic.
Shape stability: a fresh session's first run reports exactly the payload it
reported before this key existed; a caller's own max_calls=0 is not the
spent-Ticket case.
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.
Closes #1213.
What changed
A worker's Ticket can start a second run, and the MCP surface handed the whole
operator ceiling to each one. Measured at base
1aa816e0: withAGENTDESCENT_MAX_CALLS=1, twostartcalls from oneToolsserver each ranone model call and stopped
budget, so the Ticket billed 2 under a ceiling of1 — the caller never had to raise anything to exceed it.
One worker session is one Ticket (
docs/dsh-super-agent.md), so the ceiling isthat session's budget now:
Toolskeeps the ids of the runs it started and_ticket_spent()reads whatthey charged (
calls+pending_calls, so work still in flight is notbudget the next run may hand out twice; an unreadable run counts 0).
_call_limit_payloadtakesspentand clamps toceiling - spent, reportingcall_limit.ticket: {ceiling, spent, remaining}once there is earlier spend.Shape stability: a fresh session's first run returns exactly the payload it
returned before this key existed.
startbefore a run is created, with the arithmetic inthe sentence (
AGENTDESCENT_MAX_CALLS=1 is already spent by this worker's Ticket (1 call over 1 run); no run may start.), and the reply still carriescall_limit. A caller's ownmax_calls=0is not that case and keeps itsexisting path.
Not in this PR: the store as the Ticket (a store-wide aggregate would cap
campaign and pilot runs that legitimately share one),
max_concurrency, and theUSD ceiling question — those stay open on
#1082.5 files, +206/−13 (219 changed lines).
Verification
Tip SHA:
115edc746af4dac4e849f7db77f117efe05d76c1(branchagent/1082-ticket-cap, a--no-ffmerge of live main1aa816e0into thebranch).
Red first, at base
1aa816e0with only the new test file present:3 failed, 1 passed--test_second_run_is_clamped_to_what_the_ticket_has_left,test_a_spent_ticket_refuses_another_startandtest_plan_reports_what_the_ticket_has_left(the plan row asks for 9, getsthe untouched ceiling of 3 instead of the 2 the Ticket has left). The fourth
row passes at base by design: a caller's own
max_calls=0is not thespent-Ticket case.
Ran:
pytest -q tests/test_mcp_ticket_cap.py tests/test_mcp_call_limit.py tests/test_mcp.py tests/test_mcp_write_confinement.py-> 71 passed, 6 skippedtests/test_docs_links.pyrunseparately on both (22 passed each -- the system python here has no
markdownmodule): tip8029 + 22 = 8051tests, 33 failed, 10 errors,29 skipped; base
8025 + 22 = 8047, 33 failed, 10 errors, 31 skipped.The failed+error id sets are identical (43 each, 0 tip-only, 0 base-only);
the 4 extra tip tests are this PR's rows, and the 2-skip delta is the base
worktree's
.git-is-a-file shape.python -m tools.gen_api_docs --check->docs/api.mdis up to datepython -m tools.changelog_fragments check-> 15 changelog fragment(s) OKmkdocs build --strict-> rc 0 in 16.48 s with thesocialplugin excluded; the unmodified config hangs on this host atmaterial/socialpost_page, which is a host limitation, and CI'sbuildjob runs the unmodified configNot run:
starts in the guard use the offlineskill_dirfixture and stop at the cap