Skip to content

fix(mcp): algorithm_spec and plan next name the probe and a capped start - #1298

Merged
Birfy merged 1 commit into
mainfrom
agent/1296-mcp-algorithm-spec-next
Nov 27, 2026
Merged

Birfy merged 1 commit into
mainfrom
agent/1296-mcp-algorithm-spec-next

Conversation

@Birfy

@Birfy Birfy commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #1296

Base: 224e552
Tip SHA: ae85e51

What changed

On tip 224e5521, #1294 / #1297 and earlier first-run work already named plan --probe then a capped evolve on the CLI (algorithms run, a successful plan, init, the demo footers, and the host skills). MCP algorithm_spec — documented as the same verb as algorithms run — still ended a successful call with:

next: show the user this estimate; after their yes, call start with `spec`

A host that follows the tool's own next, rather than the skill / slash-command prose, would start the run unprobed and uncapped. A related gap on the same Path A surface: MCP plan(spec) with the default probe=false returned ok: true and no next field at all, while the CLI counterpart already names plan --probe, then evolve --max-calls N.

A successful algorithm_spec now returns a next that names plan(spec, probe=true) and start with max_calls from estimate.agent_calls_upper_bound (or <N> when no bound is known). A successful MCP plan without probe returns a next in the same shape. The plan tool description mentions this next. No model name is guessed. algorithm_spec still does not probe itself.

changelog.d/1296-mcp-algorithm-spec-next.md.

No change to the probe-refusal contract (ok: false, ready: false, repair next). CLI algorithms run --json is unchanged.

Verification

Tip SHA: ae85e51

Ran:

  • pytest -q -o addopts='' tests/test_mcp_algorithm_spec.py tests/test_mcp_plan_probe.py tests/test_mcp_algorithm_spec_default_out.py tests/test_mcp_algorithm_spec_target_dir.py tests/test_first_run_caps.py tests/test_mcp.py → 95 passed
  • pytest -q -o addopts='' tests/test_mcp_call_limit.py tests/test_connection_kwargs.py tests/test_cli_algorithms_run.py → 81 passed (together with the algorithm_spec file already counted above)
  • python -m tools.changelog_fragments check → 54 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
    Not run:
  • Full offline suite locally — the CI test matrix is the line

A successful algorithm_spec told the host to start unprobed and uncapped.
next now names plan(spec, probe=true) and start with max_calls from the
estimate (or <N> if none). A successful plan without probe carries the
same next shape. Refused probe contract is unchanged.

Closes #1296
@github-actions github-actions Bot added risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff agent-pr Pull request opened by an agent labels Nov 27, 2026
@Birfy

Birfy commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Review (Birfy)

Tip SHA: ae85e51
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1298 → T2 (package MCP surface plus tests and the changelog fragment)
  • pytest -q -o addopts='' tests/test_mcp_algorithm_spec.py tests/test_mcp_plan_probe.py tests/test_mcp_algorithm_spec_default_out.py tests/test_mcp_algorithm_spec_target_dir.py tests/test_first_run_caps.py tests/test_mcp.py at this tip → 95 passed
  • pytest -q -o addopts='' tests/test_mcp_call_limit.py tests/test_connection_kwargs.py tests/test_cli_algorithms_run.py → related surfaces still pass
  • python -m tools.changelog_fragments check → 54 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
    Not run:
  • Full offline suite locally — the CI test matrix on this tip is the line
    Findings:
  • No actionable defects. A successful MCP algorithm_spec now names plan(spec, probe=true) and a capped start (max_calls from estimate.agent_calls_upper_bound, or <N> when no bound is known) in next, instead of telling the host to start unprobed and uncapped. A successful MCP plan without probe returns a next in the same shape. A refused plan(..., probe=true) is still ok: false / ready: false with a repair next. CLI algorithms run --json is unchanged. No model name is guessed. algorithm_spec still does not probe itself.
    Verdict: PASS

@Birfy
Birfy enabled auto-merge (squash) November 27, 2026 10:51
@Birfy
Birfy merged commit b5980f8 into main Nov 27, 2026
12 checks passed
@Birfy
Birfy deleted the agent/1296-mcp-algorithm-spec-next branch November 27, 2026 11:17
Birfy added a commit that referenced this pull request Nov 28, 2026
Closes #1305

Base: f0edb1e
Tip SHA: 5e40eb8

## What changed

On tip `f0edb1e`, a successful MCP `algorithm_spec` already rewrites
`next` into host tool language (#1296 / #1298):

```
next: show the user this estimate; after their yes, call plan with `spec` and probe=true; if that refuses, follow its next and do not start; otherwise call start with `spec` and max_calls=N
```

When the written spec then failed to plan (missing `cases` path, too few
tasks, and the other `algorithms_run_payload` failure paths that return
`next`), the tool left the CLI retry untouched:

```
next: agentdescent plan <spec_path> --probe
```

A host that followed the success-path `next` would call the `plan` tool;
a host that followed this failed-path `next` was told to run a CLI verb
it may not have.

A failed-plan `algorithm_spec` now returns:

```
next: fix the written spec, then call plan with that spec and probe=true; if that refuses, follow its next and do not start
```

The `algorithm_spec` tool description mentions this failed-plan `next`.
No model name is guessed. The tool still does not start a run or probe.
A successful `algorithm_spec` next and the CLI `algorithms run`
failed-plan next are unchanged.

`changelog.d/1305-mcp-algorithm-spec-failed-next.md`.

## Verification

Tip SHA: 5e40eb8

Ran:
- `pytest -q -o addopts='' tests/test_mcp_algorithm_spec.py
tests/test_mcp_algorithm_spec_default_out.py
tests/test_mcp_algorithm_spec_target_dir.py tests/test_mcp_plan_probe.py
tests/test_cli_algorithms_run.py tests/test_mcp.py
tests/test_first_run_caps.py tests/test_plan_probe.py` → 144 passed
- `python -m tools.changelog_fragments check` → 58 changelog fragment(s)
OK
- `python -m tools.gen_api_docs --check` → docs/api.md is up to date
Not run:
- Full offline suite locally — the CI test matrix is the line
Birfy added a commit that referenced this pull request Nov 28, 2026
Closes #1307

Base: f9c35b5
Tip SHA: 001b346

## What changed

On tip `f9c35b5`, MCP `algorithm_spec` and `plan` already rewrite `next`
into host tool language (#1296 / #1298 / #1303 / #1305). MCP `demo`
still returned the shared CLI `demo --json` list untouched:

```
next: agentdescent show  <run_id>
      agentdescent apply <run_id> --dry-run
      agentdescent algorithms run gepa … --out spec.json
      agentdescent plan spec.json --probe
      agentdescent evolve spec.json --max-calls <N>
      agentdescent doctor
```

A host that followed the `algorithm_spec` or `plan` `next` would call
those tools; a host that followed this `demo` `next` was told to run CLI
verbs it may not have.

A successful MCP `demo` now returns:

```
next: call show with this run_id
      call apply with this run_id and dry_run=true to preview the write
      to run this card on the user's data, call algorithm_spec with the name, their path and cases, and model and base_url (never guess those), plus rounds=1 and workers=1; if that refuses, follow its next and do not start; otherwise follow its next
```

When no algorithm was named, the last step names `list_algorithms` and
then that same `algorithm_spec` call (there is no MCP `init` tool). A
real-model-only card's refusal names `algorithm_spec` and
`describe_algorithm`, not `agentdescent algorithms run`. The `demo` tool
description mentions this tool-language `next`. No model name is
guessed. The tool still does not start a real run or probe. The CLI
`demo` next and live-model refusal are unchanged.

`changelog.d/1307-mcp-demo-next.md`.

## Verification

Tip SHA: 001b346

Ran:
- `pytest -q -o addopts='' tests/test_mcp.py tests/test_demo.py
tests/test_mcp_algorithm_spec.py tests/test_mcp_plan_probe.py
tests/test_first_run_caps.py` → 125 passed
- `python -m tools.changelog_fragments check` → 59 changelog fragment(s)
OK
- `python -m tools.gen_api_docs --check` → docs/api.md is up to date
Not run:
- Full offline suite locally — the CI test matrix is the line
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 risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: algorithm_spec next tells the host to start without plan(probe=true) or max_calls

1 participant