Repository navigation
Description
Problem
The run-level call cap shipped for the CLI (#1166, PR #1167) and the operator ceiling shipped for the process (#1082, PR #1181), but neither is reachable from the MCP surface. plan and start accept budget_usd and usd_per_call and nothing else:
agentdescent/mcp.py:669-671—plan(self, spec, usd_per_call=None, budget_usd=None, probe=False)agentdescent/mcp.py:714-715—start(self, spec, budget_usd=None, usd_per_call=None)agentdescent/mcp.py:757—runstore.launch(rd, budget_usd=..., usd_per_call=..., env=...)— nomax_calls- the tool wrappers mirror those signatures:
:1393-1396(plan),:1404-1416(start)
So an MCP host that wants "at most N model calls for this run" has exactly one lever, the process-wide AGENTDESCENT_MAX_CALLS (agentdescent/runstore.py:107, operator_max_calls :116), which it cannot lower per call — and a host that does not set it gets no per-call bound at all. The CLI already validates this through build_call_limit (agentdescent/cli.py:2731-2733, evolvespec.py:1113-1135), including the refusal that names the field and the value.
This is user-perceivable: a caller of the MCP start tool cannot state a call cap, so the transcript of a runaway run shows no bound the host asked for.
Scope
- Give
planandstart(both the tool methods and themaybe_toolwrappers)max_calls: Optional[int] = Noneandmax_usd: Optional[float] = None. - Validate them through
build_call_limit(max_calls=..., max_usd=..., usd_per_call=...), so a bad value or amax_usdwithoutusd_per_callrefuses with the same wording the CLI uses — one contract, not two wordings. - Enforce the operator ceiling with the same
minthe run store applies: a caller may lowerAGENTDESCENT_MAX_CALLS, never raise it. - Put the effective limit in the returned payload (
planandstart), naming what was asked for and what will be enforced when the ceiling bound it — the same distinctionAGENTDESCENT_MAX_CALLS_REQUESTEDalready carries across the detach boundary (runstore.py:109-134). startmust pass the clampedmax_callsintorunstore.launchso the detached child runs under it.- Offline tests for: cap accepted and reported;
max_usdwithout price refused with the CLI wording; a caller's cap above the operator ceiling clamped and labelled; the nested-start stub (mcp.py:726-737) unchanged. - Docs row for the two tool arguments plus one changelog fragment.
Acceptance
- An MCP
startwithmax_calls: 1launches a run whosestatusshows the cap and stops at it; with no argument the behaviour is exactly today's. max_usdalone returns the CLI'smax_usd needs usd_per_callrefusal, not a new sentence.- With
AGENTDESCENT_MAX_CALLS=2, a caller asking formax_calls: 9reports 2 enforced / 9 requested and cannot raise it. pytest -qstays offline and green; no new dependency.
Not in scope
max_concurrency, doctor reporting of the ceilings, any USD default for un-priced runs (a process-wide dollar ceiling would turn every un-priced run into a SpecError through require_budget_pair).
Source
- feat(run): stop a worker run on max_calls / max_usd with a named stop reason #1166 / PR feat(run): stop a worker run on max_calls / max_usd at the call (#1166) #1167 (run-level cap), #963 remainder: write-dir confinement, per-Ticket budget caps, host MCP-config scrub #1082 / PR feat(runstore): operator call ceiling
AGENTDESCENT_MAX_CALLS(Partial #1082) #1181 (operator ceiling; its claim comment names "the MCP tool arguments" as explicitly deferred). - Read at
mainf5017f930153e2ab9ca5e3b8f3cc4f0c7c0bd8ec.
Written-by: AgentDescent Lead
Activity
HugoXK commentedon Nov 20, 2026
Branch
agent/1184-mcp-call-limitfromf5017f93; local tip4015bb8f(4 files, +239/−13). PR follows in this session.Gap reproduced on clean
f5017f93with onlytests/test_mcp_call_limit.pyadded: 8 failed, 2 passed on the final file (the earlier6was the same run before its last two rows existed). The eight: 7 areTypeError: Tools.plan() / Tools.start() got an unexpected keyword argument 'max_calls' / 'max_usd', the eighth isKeyError: 'call_limit'on the plan payload that names no cap — the surface does not exist, which is the issue. The two green rows are the no-cap, behaviour-unchanged ones, which must hold before and after; the behaviour rows (stop at the cap, ceiling instop_detail,--max-calls 2in the child argv) are asserted green at the tip.At the tip:
tests/test_mcp_call_limit.py10 passed, focused set of 7 files 116 passed,tools.changelog_fragments checkand bothgen_*_docs --checkclean.