Repository navigation
Description
What happens
On tip f0edb1e (after #1304), 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 fails to plan (missing cases path, plan refusal, and the other algorithms_run_payload failure paths that still return next), algorithm_spec leaves the CLI retry untouched:
next: agentdescent plan <spec_path> --probe
That string was added for the CLI in #1299, and tests/test_mcp_algorithm_spec.py currently pins it. A host that followed the success-path next would call the plan tool; a host that followed this failed-path next is told to run a CLI verb it may not have, and is not told to call plan(..., probe=true).
This is the same leftover-surface class as #1296 / #1299 / #1303, now for the failure path of MCP algorithm_spec.
Repro
Fresh clone of ThinkFlowLab/agentdescent at f0edb1e. pip install -e ".[mcp]". Isolated AGENTDESCENT_HOME. No network is required: the plan fails because the cases file is missing.
from agentdescent.mcp import Tools
r = Tools(None).algorithm_spec(
"gepa", "/path/to/prompt.md", "/path/to/missing.jsonl",
model="deepseek-v4-flash",
base_url="https://example.invalid/v1",
)
# r["ok"] is False, r["spec_path"] exists, error names `cases`
# r["next"] == "agentdescent plan <spec_path> --probe"By contrast, the same tool's success path already returns an MCP plan(..., probe=true) next, not a CLI command.
Expected
- When MCP
algorithm_specwrites a spec but planning fails,nextshould name a fix of the written spec and thenplan(..., probe=true)in tool language, for example:fix the written spec, then call plan with that spec and probe=true; if that refuses, follow its next and do not start. It must not sayagentdescent planorevolve/start. - The CLI
algorithms runfailed-plan next staysagentdescent plan <spec> --probe(text form stillnext: fix <spec>, then ...). A successfulalgorithm_specnext, MCPplan, and CLIplan/algorithms run --probenext lines are unchanged. - No model name is guessed. The tool still does not start a run or probe.
Suggested fix
- In
agentdescent/mcp.py(algorithm_spec), after the CLI helper returns, rewrite a failed-plannextthat starts withagentdescent planinto the MCP repair sentence above. Do not changealgorithms_run_payload(that string is still correct for the CLI). - Pin this in
tests/test_mcp_algorithm_spec.py(replace the current cli: algorithms run failed-plan next still says plan <spec>, omitting --probe #1299 pin on the MCP path). - Mention the failed-plan
nextin thealgorithm_spectool description. changelog.d/<n>-mcp-algorithm-spec-failed-next.md.
Acceptance
- MCP
algorithm_specthat writes a spec and then fails to plan returnsok: falseand anextthat names fixing the written spec andplan(..., probe=true), with noagentdescent planand nostart/evolve. - A successful
algorithm_specstill namesplan(spec, probe=true)and then the cappedstart. - CLI
algorithms runfailed-plan JSONnextis stillagentdescent plan <spec> --probe. 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.pypasses, including the new pins.
Activity
fix(mcp): demo next names Path A tools, not CLI verbs (#1308)