diff --git a/agentdescent/integrations/__init__.py b/agentdescent/integrations/__init__.py index ee85e690..f3fb59c7 100644 --- a/agentdescent/integrations/__init__.py +++ b/agentdescent/integrations/__init__.py @@ -401,8 +401,12 @@ def mcp_manifest(launcher: Optional[List[str]] = None) -> Dict[str, object]: --- Use the agentdescent skill. The target is `$ARGUMENTS` (a path, optionally -followed by a cases file). Run `doctor`, build the spec, `plan` it, show me the -spec and the estimate, and wait for my yes before `start`. +followed by a cases file). Run `doctor`, build the spec, then `plan` it with +`--probe` / `probe=true`. If the probe refuses, give me its `next` and do not +`start`. Show me the spec and the estimate, and wait for my yes before +`start` / `evolve` with `max_calls` (and `max_usd` beside `usd_per_call` when +a price is known), starting at the plan's `agent_calls_upper_bound` (or +smaller for a trial). If I named a method that is in `agentdescent algorithms list` (for example RRSI or archive_selection), set `algorithm` in the spec (or pass `--algorithm` to @@ -439,12 +443,16 @@ def mcp_manifest(launcher: Optional[List[str]] = None) -> Dict[str, object]: call `algorithm_spec` with the name, the absolute path, the absolute cases file and only the params they gave (validate with `describe_algorithm` / `show` first); it writes and plans the spec and returns `spec`. Run `doctor` - first, show the resolved algorithm card (including fidelity / surface) and - estimate, and wait for my yes before `start` with that `spec`. Same + first, then `plan` that `spec` with `--probe` / `probe=true`. If the probe + refuses, give me its `next` and do not `start`. Show the resolved algorithm + card (including fidelity / surface) and estimate, and wait for my yes + before `start` with that `spec` and `max_calls` (and `max_usd` beside + `usd_per_call` when a price is known), starting at the plan's + `agent_calls_upper_bound` (or smaller for a trial). Same apply/cancel/resume rules as `/evolve`. Without MCP: `agentdescent algorithms run [cases.jsonl] [--param k=v...] [--rounds N] [--workers N]` - (init + plan; then `evolve` after yes). For a quick trial pass - `--rounds 1 --workers 1`. + (init + plan), then `plan --probe` and `evolve --max-calls N` after + yes. For a quick trial pass `--rounds 1 --workers 1`. If they only named a method with no path, `show` it and ask whether to `run`. """ diff --git a/agentdescent/mcp.py b/agentdescent/mcp.py index 6321bb80..48dca1dd 100644 --- a/agentdescent/mcp.py +++ b/agentdescent/mcp.py @@ -149,8 +149,13 @@ def advanced_from_env(environ: Optional[Dict[str, str]] = None) -> bool: "allowed root; `agentdescent..spec.json`) unless `out` names " "another path under one of those roots -- never inside " "a directory target -- and returns the plan estimate plus `spec`, the dict " - "to pass to start. It " - "starts nothing: show the user the estimate and get a yes before start. " + "to pass to start after a probed plan and a yes. It starts nothing and " + "does not probe or set a per-call cap: after it returns, call " + "`plan(spec, probe=true)` (or `plan --probe`); if the probe refuses, " + "give the user `next` and do not start (`ok: false`, `ready: false`). " + "Show the estimate, get a yes, then `start` with `max_calls` (and " + "`max_usd` beside `usd_per_call` when a price is known), starting at " + "the plan's `agent_calls_upper_bound` (or smaller for a trial). " "`model`/`base_url` come from the user, never guess them."), "plan": ( "Validate an EvolveSpec and estimate its cost WITHOUT running anything. Resolves " diff --git a/changelog.d/1228-slash-command-probe-cap.md b/changelog.d/1228-slash-command-probe-cap.md new file mode 100644 index 00000000..d201d96b --- /dev/null +++ b/changelog.d/1228-slash-command-probe-cap.md @@ -0,0 +1,7 @@ +Fixed +Installed `/evolve` and `/algorithms run` slash commands (and the MCP +`algorithm_spec` description) now name the same first-run `plan --probe` / +`probe=true` preflight and `max_calls` / `--max-calls` cap as `SKILL.md` +and the CLI `next:` line, so a host following the command no longer starts +a first real run without them. Claude / Codex / OpenCode command files stay +byte-identical (#1228). diff --git a/integrations/claude-code/commands/algorithms.md b/integrations/claude-code/commands/algorithms.md index b08f5dba..51c33b81 100644 --- a/integrations/claude-code/commands/algorithms.md +++ b/integrations/claude-code/commands/algorithms.md @@ -27,11 +27,15 @@ Parse `$ARGUMENTS` (trim; empty means `list`): call `algorithm_spec` with the name, the absolute path, the absolute cases file and only the params they gave (validate with `describe_algorithm` / `show` first); it writes and plans the spec and returns `spec`. Run `doctor` - first, show the resolved algorithm card (including fidelity / surface) and - estimate, and wait for my yes before `start` with that `spec`. Same + first, then `plan` that `spec` with `--probe` / `probe=true`. If the probe + refuses, give me its `next` and do not `start`. Show the resolved algorithm + card (including fidelity / surface) and estimate, and wait for my yes + before `start` with that `spec` and `max_calls` (and `max_usd` beside + `usd_per_call` when a price is known), starting at the plan's + `agent_calls_upper_bound` (or smaller for a trial). Same apply/cancel/resume rules as `/evolve`. Without MCP: `agentdescent algorithms run [cases.jsonl] [--param k=v...] [--rounds N] [--workers N]` - (init + plan; then `evolve` after yes). For a quick trial pass - `--rounds 1 --workers 1`. + (init + plan), then `plan --probe` and `evolve --max-calls N` after + yes. For a quick trial pass `--rounds 1 --workers 1`. If they only named a method with no path, `show` it and ask whether to `run`. diff --git a/integrations/claude-code/commands/evolve.md b/integrations/claude-code/commands/evolve.md index 80760141..12b906b0 100644 --- a/integrations/claude-code/commands/evolve.md +++ b/integrations/claude-code/commands/evolve.md @@ -4,8 +4,12 @@ argument-hint: [cases.jsonl] --- Use the agentdescent skill. The target is `$ARGUMENTS` (a path, optionally -followed by a cases file). Run `doctor`, build the spec, `plan` it, show me the -spec and the estimate, and wait for my yes before `start`. +followed by a cases file). Run `doctor`, build the spec, then `plan` it with +`--probe` / `probe=true`. If the probe refuses, give me its `next` and do not +`start`. Show me the spec and the estimate, and wait for my yes before +`start` / `evolve` with `max_calls` (and `max_usd` beside `usd_per_call` when +a price is known), starting at the plan's `agent_calls_upper_bound` (or +smaller for a trial). If I named a method that is in `agentdescent algorithms list` (for example RRSI or archive_selection), set `algorithm` in the spec (or pass `--algorithm` to diff --git a/tests/test_first_run_caps.py b/tests/test_first_run_caps.py index c7f200a2..a0de1baf 100644 --- a/tests/test_first_run_caps.py +++ b/tests/test_first_run_caps.py @@ -22,7 +22,7 @@ import pytest from agentdescent import cli -from agentdescent.integrations import skill_text +from agentdescent.integrations import ALGORITHMS_COMMAND, EVOLVE_COMMAND, skill_text ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ALGORITHMS = ("gepa", "archive_selection") @@ -57,6 +57,21 @@ def test_shared_host_skill_names_the_per_call_cap(): assert "--probe" in text # the preflight stays the first step +def test_slash_commands_name_the_probe_and_the_cap(): + """#1228: /evolve and /algorithms run must name the same first-run + preflight and per-call cap as SKILL.md / the CLI next: line.""" + for text in (EVOLVE_COMMAND, ALGORITHMS_COMMAND): + assert "probe" in text + assert "max_calls" in text or "--max-calls" in text + run_branch = ALGORITHMS_COMMAND.split("**`run", 1)[1] + assert "probe" in run_branch + assert "--max-calls" in run_branch + assert "max_calls" in run_branch + # The run branch must not still tell the host to start from + # algorithm_spec / a bare algorithms run with no cap. + assert "then `evolve` after yes" not in run_branch + + def test_plugin_quickstart_habits_name_the_per_call_cap(): text = _read("docs", "plugin-quickstart.md") assert "--max-calls" in text diff --git a/tests/test_mcp_algorithm_spec.py b/tests/test_mcp_algorithm_spec.py index 2e1a925d..1caaa678 100644 --- a/tests/test_mcp_algorithm_spec.py +++ b/tests/test_mcp_algorithm_spec.py @@ -108,6 +108,9 @@ def test_same_object_as_algorithms_run_json(tmp_path, capsys): def test_description_is_written_for_the_model(): text = TOOL_DESCRIPTIONS["algorithm_spec"] assert "algorithms run" in text and "start" in text and "never guess" in text + # #1228: the tool itself still only builds + plans; the description must + # require a follow-up probe and a capped start, not a bare start. + assert "probe=true" in text and "max_calls" in text def test_params_object_is_passed_through_not_re_split(tmp_path):