Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions agentdescent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4639,8 +4639,11 @@ def _cmd_algorithms_run(a: argparse.Namespace) -> int:
then_line=then_line)
calls = (payload.get("estimate") or {}).get("agent_calls_upper_bound")
if (getattr(a, "rounds", None) is None and getattr(a, "workers", None) is None
and isinstance(calls, (int, float)) and calls > QUICK_TRIAL_CALLS):
# The kind defaults plan a full run; name the one-command cheap trial (#707).
and isinstance(calls, (int, float)) and calls > QUICK_TRIAL_CALLS
and (probe is None or probe.get("ok", True))):
# The kind defaults plan a full run; name the one-command cheap trial
# (#707). Not after a refused probe: `next:` is the outcome there, and a
# hint printed after it reads as the last word on the refusal (#1106).
print(" (for a quick trial: re-run with --rounds 1 --workers 1)")
# Same contract as `plan`: a refused probe exits non-zero before a run (#1048).
return 0 if probe is None or probe.get("ok", True) else 1
Expand Down
7 changes: 7 additions & 0 deletions changelog.d/1106-algorithms-run-hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Fixed
`algorithms run` no longer prints the `--rounds 1 --workers 1` quick-trial hint
after a refused `--probe`: with the kind's default rounds and workers the hint
used to land below `next: renew the subscription …`, so the last line on screen
answered a question the refusal had already answered. The hint still prints
after a passing probe and when no probe runs, and every other line of the
refusal is unchanged (#1106).
53 changes: 53 additions & 0 deletions tests/test_plan_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,59 @@ def test_algorithms_run_human_form_exits_nonzero_too(tmp_path, monkeypatch, endp
assert "next: agentdescent evolve" not in out


def _algorithms_run_default_shape_args(tmp_path, *, extra=(),
base_url="http://127.0.0.1:1"):
"""`algorithms run` without `--rounds` / `--workers`: the kind's defaults."""
return ["algorithms", "run", "gepa", _prompt(tmp_path), _cases(tmp_path),
"--agent", "openai_compatible", "--model", "m",
"--key-env", "FAKE_KEY", "--base-url", base_url,
"--out", str(tmp_path / "algo.spec.json"), *extra]


def test_a_refused_probe_on_the_default_shape_ends_on_the_next_line(
tmp_path, monkeypatch, endpoint):
"""The last human line is `next:`, not the #707 quick-trial hint (#1106).

The row above passes `--rounds 1 --workers 1`, which is what hides this: with
the defaults the plan is large enough for the hint, and a refused probe used
to print it after `next:` -- so a host or a reader took the hint for the
outcome of the refusal.
"""
endpoint(body=ARK_SUBSCRIPTION)

code, out, err = _run(_algorithms_run_default_shape_args(
tmp_path, extra=["--probe"], base_url=_Handler.url))

assert code == 1, (code, out, err)
assert "probe: agent failed" in out + err
lines = out.strip().splitlines()
assert lines[-1].startswith("next: renew the subscription"), lines[-3:]
assert not any("for a quick trial" in line for line in lines), lines[-3:]
assert "next: agentdescent evolve" not in out


def test_the_default_shape_still_names_the_quick_trial_without_a_probe(tmp_path,
monkeypatch):
"""The #707 hint is unchanged when nothing refused; it is only gated on that."""
code, out, err = _run(_algorithms_run_default_shape_args(tmp_path))

assert code == 0, (code, out, err)
assert out.strip().splitlines()[-1] == (
" (for a quick trial: re-run with --rounds 1 --workers 1)")


def test_the_default_shape_still_names_the_quick_trial_after_a_passing_probe(
tmp_path, monkeypatch, endpoint):
endpoint(code=200)

code, out, err = _run(_algorithms_run_default_shape_args(
tmp_path, extra=["--probe"], base_url=_Handler.url))

assert code == 0, (code, out, err)
assert out.strip().splitlines()[-1] == (
" (for a quick trial: re-run with --rounds 1 --workers 1)")


def test_the_probe_caps_the_reply_budget_and_the_wait(tmp_path, monkeypatch, endpoint):
"""One word is bought, not 4096 tokens (#1048 review)."""
import agentdescent.probe as probe_module
Expand Down
Loading