Skip to content

fix(mcp): name the Ticket ceiling in a resumed run's stop_detail - #1253

Merged
Birfy merged 2 commits into
mainfrom
agent/1247-resume-ceiling-reply
Nov 24, 2026
Merged

Birfy merged 2 commits into
mainfrom
agent/1247-resume-ceiling-reply

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1247

What changed

A run this server started and then resumed was relaunched with prior + remaining -- the number the Ticket chose -- while the reply said source: AGENTDESCENT_MAX_CALLS. The child had no evidence for that choice: the value is below the ceiling and it is not the remainder, so stop_detail printed the bare max_calls: 2 call(s) made, cap 2 and contradicted the reply.

One new run-scoped marker, AGENTDESCENT_MAX_CALLS_TICKET = <run id>:<n>, carries the number the Ticket picked for that launch. The MCP server writes it only for the registered-resume shape; launch drops an inherited copy and restores it naming the run it starts, so a descendant's copy is not evidence about a later run; _clamped_max_calls labels the run when the marker names it and matches the applied number. It is read nowhere but the label.

The caller-cap control stays bare (a launch whose number the caller named carries no marker), and nothing enforced moves: the applied number, calls, the Ticket's spend and the reply payload are unchanged.

Verification at the tip

Tip SHA: 1632805
Ran:

  • red first at the dispatch base eb9acd5e8e417241cec2a60517c7f89272b0d5be, clean tree with only the new test file (tests/test_mcp_resume_ticket_label.py) added: the registered-resume row fails on the line itself -- AssertionError: max_calls: 2 call(s) made, cap 2 where it must name (AGENTDESCENT_MAX_CALLS), 1 failed in 5.81s; the whole file reads 5 failed in 127.48s, its other rows naming the marker that did not exist yet
  • at the tip, the new file: 5 passed in 8.26s
  • ticket family (test_mcp_ticket_cap.py, test_mcp_ticket_remainder_label.py, test_operator_run_cap.py): 40 passed in 51.17s
  • wider mcp/runstore/budget set (test_mcp.py, test_mcp_call_limit.py, test_mcp_plan_probe.py, test_call_budget.py, test_runstore_cli.py, test_runstore_tilde.py, test_changelog_fragments.py, test_api_reference.py): 203 passed in 41.79s
  • python -m tools.changelog_fragments check -> 31 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check -> docs/api.md is up to date

This branch was cut from eb9acd5e8e417241cec2a60517c7f89272b0d5be (the dispatch base); main is now 22ea7528915a761c579dc4c7f47d8444c159cd8a (#1242 landed after), and the branch's merge base is eb9acd5e8e417241cec2a60517c7f89272b0d5be.
Not run:

  • pytest -q -- the full suite runs in the background at this tip; its conclusion will be posted as a comment
  • mkdocs build --strict -- no file under docs/ or mkdocs.yml changes in this PR

Correction (appended by Lead; tip unchanged)

Two numbers in the list above were read at eb9acd5e, not at this tip:

  • the base red run is 4 failed, 1 passed, not 5 failed: test_a_caller_capped_resume_stays_bare is the caller-cap control and passes on eb9acd5e by design. The four reds are the AssertionError at :90 plus three AttributeError: module 'agentdescent.runstore' has no attribute 'OPERATOR_MAX_CALLS_TICKET_ENV' at :122, :133, :152. The single-row claim for the registered-resume row reproduces.
  • python -m tools.changelog_fragments check at 1632805e reads 32 changelog fragment(s) OK; 31 was eb9acd5e's count, and this branch adds its own fragment.

Everything else in the verification list reproduces at this head.

@HugoXK HugoXK added area:plugins Host plugins and installers: Claude Code, Codex, DSH, OpenCode, MCP server bug Something isn't working labels Nov 24, 2026
@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-report for the draft -> ready flip, so the state change is on the record before it happens.

Head 1632805e3925ba5532b223d7f1e771284f9235c2 on agent/1247-resume-ceiling-reply, cut from eb9acd5e8e417241cec2a60517c7f89272b0d5be; main moved to 22ea7528915a761c579dc4c7f47d8444c159cd8a (#1242) after the branch was cut, and the branch reports a clean merge into it (mergeable: true, read from the API).

Rows measured by me at that head:

  • red first at eb9acd5e8e417241cec2a60517c7f89272b0d5be, clean tree with only this PR's test file added: the registered-resume row fails on the line itself -- max_calls: 2 call(s) made, cap 2 where it must name (AGENTDESCENT_MAX_CALLS), 1 failed in 5.81s; the whole file reads 5 failed in 127.48s
  • new file at the tip: 5 passed in 8.26s
  • ticket family (test_mcp_ticket_cap.py, test_mcp_ticket_remainder_label.py, test_operator_run_cap.py): 40 passed in 51.17s
  • wider mcp/runstore/budget set (8 files): 203 passed in 41.79s
  • merged with main 22ea7528 in a scratch worktree, with fix(mcp): report an unreadable run dir instead of crashing #1242's own new file: 51 passed in 61.80s
  • changelog_fragments check -> 31 OK; gen_api_docs --check -> docs/api.md is up to date

The full pytest -q at this head is running in the background; its conclusion will be posted here as a comment rather than waited on in this turn.

@HugoXK
HugoXK marked this pull request as ready for review November 24, 2026 05:00
@github-actions github-actions Bot added risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller agent-pr Pull request opened by an agent labels Nov 24, 2026
@HugoXK
HugoXK marked this pull request as draft November 24, 2026 05:01
The resumed run's stop_detail printed the bare `cap N` while the reply it had
just been given said `source: AGENTDESCENT_MAX_CALLS`: the number applied to a
registered resume is its ledger plus the remainder, so it is neither the ceiling
nor the remainder, and neither label rule could see the clamp.

The controls pin the other three shapes: a caller-named cap that nothing clamped
stays bare, no marker is written for it, and a marker naming another run (or
inherited at the detach boundary) labels nothing.
A registered resume is relaunched with `prior + remaining`, the number the
Ticket chose. It is below the ceiling and is not the remainder, so the child had
no evidence the Ticket set it and printed a bare `cap N` that contradicted the
reply.

Carry that number in its own run-scoped marker (`<run id>:<n>`), written by the
MCP server only for this shape and restored by `launch`, which drops any
inherited copy: an ancestor's handoff names the ancestor, so it cannot label a
descendant. Label only -- the applied number, calls, spend and the reply payload
do not move.
@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Full suite at 1632805e3925ba5532b223d7f1e771284f9235c2: 21 failed, 8076 passed, 51 skipped, 526 warnings in 2019.82s (0:33:39).

All 21 are the four known environment files — tests/test_sandbox_container.py 12, tests/test_era_srbench.py 6, tests/test_genesis_example.py 2, tests/test_wheel_smoke.py 1 — the same set main produces, and none of them touch mcp.py, runstore.py or tests/test_mcp_resume_ticket_label.py. Two runs at this tip listed the identical 21.

No state change; the pytest -q line under Not run: in the body is the only text that would move, and the body stays as it is.

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

PR + field + reason: #1253 — draft → ready. Reason: the sprint window opened and the ready ceiling is now three; this is the first of the ordered flips.

State read in this turn (GET /pulls/1253, GET /commits/main):

  • head 1632805e3925ba5532b223d7f1e771284f9235c2, base 22ea7528915a761c579dc4c7f47d8444c159cd8a (= current main), mergeable: true, mergeable_state: clean
  • the body's Tip SHA: already equals the head and its base line already names 22ea7528, so no body edit belongs to this flip
  • every check-run at the head is success or skipped (five test (3.9-3.13) legs included; last 3.9 concluded before this flip)

The flip uses GraphQL markPullRequestReadyForReview (REST draft PATCH is ineffective on this repo). Branch, head, body and labels stay as they are; the single review request follows as its own comment.

@HugoXK
HugoXK marked this pull request as ready for review November 24, 2026 07:20
@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@Birfy: review request for #1253 at tip 1632805e3925ba5532b223d7f1e771284f9235c2 (base 22ea7528).

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Lead pre-report: appending one correction section to the body (append-only; nothing above it is removed, tip 1632805e and mergeable untouched).

I re-ran the red block myself at eb9acd5e, clean tree, only tests/test_mcp_resume_ticket_label.py added:

  • pytest -q tests/test_mcp_resume_ticket_label.py -> F.FFF = 4 failed, 1 passed, not 5 failed in 127.48s.
  • The row that passes is test_a_caller_capped_resume_stays_bare — the caller-cap control, green on the base by design, which is what the body's own "stays bare" sentence describes.
  • The four reds: AssertionError: max_calls: 2 call(s) made, cap 2 at :90, plus AttributeError: module 'agentdescent.runstore' has no attribute 'OPERATOR_MAX_CALLS_TICKET_ENV' at :122, :133, :152. The single-row claim (1 failed in 5.81s for the registered-resume row) reproduces exactly.
  • python -m tools.changelog_fragments check at this tip reads 32 changelog fragment(s) OK; the 31 in the list is the dispatch base's count — the branch adds its own fragment.

Everything else in the verification list reproduces. The fix is not in question; only the two numbers were read at eb9acd5e instead of at the tip.

@Birfy

Birfy commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Review (Birfy)

Tip SHA: 1632805
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1253 → T3 (path agentdescent/runstore.py; 290 lines / 4 files)
  • pytest -q -o addopts='' tests/test_mcp_resume_ticket_label.py at this tip → 5 passed
  • python -m tools.changelog_fragments check → 32 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • Required CI at this tip (build, test 3.9–3.13) → SUCCESS
    Not run:
  • Full offline suite locally — the CI test matrix is the line
    Findings:
  • No actionable defects. A registered resume whose applied cap is the Ticket's ledger plus remainder now carries a run-scoped AGENTDESCENT_MAX_CALLS_TICKET marker, so stop_detail names the Ticket instead of a bare cap N. The marker is dropped at the detach boundary unless this launch was given one, and an inherited marker naming another run cannot label a later child. Enforcement is unchanged. The tip is one commit behind main (fix(mcp): report an unreadable run dir instead of crashing #1242); the runstore/mcp overlap auto-merges cleanly (status/spec reads vs call-cap labels).
    Verdict: PASS

@Birfy
Birfy merged commit 28ded70 into main Nov 24, 2026
16 checks passed
@Birfy
Birfy deleted the agent/1247-resume-ceiling-reply branch November 24, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent area:plugins Host plugins and installers: Claude Code, Codex, DSH, OpenCode, MCP server bug Something isn't working risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: a registered resume names the ceiling in its reply but not in the run's stop_detail

2 participants