Skip to content

fix(dispatch): drive one-shot CLI agents (claude/codex) with the prompt at launch#127

Merged
vu1n merged 1 commit into
mainfrom
dispatch/cli-agent-drive
Jun 23, 2026
Merged

fix(dispatch): drive one-shot CLI agents (claude/codex) with the prompt at launch#127
vu1n merged 1 commit into
mainfrom
dispatch/cli-agent-drive

Conversation

@vu1n

@vu1n vu1n commented Jun 23, 2026

Copy link
Copy Markdown
Owner

dispatch drove every worker fork-idle then session send — the opencode server model. claude/codex are one-shot agent -p PROMPT: the prompt must ride the launch argv, and a later send can't drive a finished one-shot. So dispatch --agent claude (the documented default) booted VMs that never ran a turn → silent 0/0 — why the Opus-via-pillbox -k path never actually worked.

Fix

CLI-harness agents fork with the prompt (run --detach -- "<prompt>") and are awaited+graded; server agents keep fork-idle + send + retry (byte-identical).

  • WorkerDriver: fork(i, first_turn) + first_turn_driven_on_fork(i) (classified via agents::lookup(...).server.is_none(), default-agent-aware).
  • drive_to_grade branches: CLI = wait+grade (no send, no in-session retry — best-of-k is the variance lever); server = the existing send→wait→grade→retry loop.
  • --segments declined for CLI agents (a one-shot can't chain in-session) → exit 2.

Verification

  • Live: scripts/smoke/dispatch-claude.shdispatch -k 2 --agent claude → 2/2 Opus workers scored, winner pulled, result.txt recovered. Also exercises 2 concurrent claude forks through the (now-fixed fix(vault): degraded lease so a poisoned pending doesn't brick valid tokens #125) vault.
  • fmt + clippy (--no-default-features and --features libkrun, -D warnings) + 581 unit tests green incl. the new one-shot test.

Implemented via codex-rescue, independently diff-reviewed + live-smoked. Follow-ups (separate): eval-harness kill -9 mid-pre_refresh; run rc=0 on fork-fail.

…pt at launch

`dispatch` drove every worker fork-idle then `session send` — the opencode SERVER
model. claude/codex are one-shot `agent -p PROMPT`: the prompt must ride the launch
argv, and a later `session send` can't drive a finished one-shot. So `dispatch
--agent claude` (the documented default) booted VMs that never ran a turn → silent
0/0. This is why the Opus-via-pillbox `-k` path never actually worked.

Fix: CLI-harness agents fork WITH the prompt (`run --detach -- "<prompt>"`) and are
awaited+graded; server agents keep fork-idle + send + retry (byte-identical).
- WorkerDriver: `fork(i, first_turn)` + `first_turn_driven_on_fork(i)` (classified by
  `agents::lookup(...).server.is_none()`, default-agent-aware via resolve_run_config).
- drive_to_grade branches: CLI = wait+grade, no send, no in-session retry (best-of-k is
  the variance lever); server = the existing send→wait→grade→retry loop, unchanged.
- `--segments` declined for CLI agents (a one-shot can't chain in-session) → exit 2.

Live-verified: scripts/smoke/dispatch-claude.sh (`dispatch -k 2 --agent claude` →
2/2 Opus workers scored, winner pulled, result.txt recovered) — also exercises 2
concurrent claude forks through the (now-fixed) vault. fmt + clippy (both feature
sets) + 581 unit tests green incl. the new one-shot test. Implemented via
codex-rescue, independently verified + live-smoked here.
@vu1n vu1n merged commit 79cab98 into main Jun 23, 2026
3 checks passed
@vu1n vu1n deleted the dispatch/cli-agent-drive branch June 23, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant