Skip to content

feat(spawn): allow passing an initial prompt to the spawned agent#212

Open
Eotel wants to merge 3 commits into
fujibee:mainfrom
Eotel:feat/spawn-initial-prompt
Open

feat(spawn): allow passing an initial prompt to the spawned agent#212
Eotel wants to merge 3 commits into
fujibee:mainfrom
Eotel:feat/spawn-initial-prompt

Conversation

@Eotel

@Eotel Eotel commented Jun 24, 2026

Copy link
Copy Markdown

Motivation

spawn.sh boots a new agent with a hardcoded initial prompt of only the actas slash command (/<cmd> actas <name>). The agent registers, then goes idle. For a codex peer this is a problem: codex has no Monitor — no real-time message delivery (see docs/codex-monitor-beta.md) — so a message you send after spawn is never noticed by the idle session. The leader has no clean way to hand a one-shot task to a freshly-spawned codex peer.

Change

Add an optional --prompt <text> to spawn.sh. When provided, the boot prompt becomes the existing actas slash command followed (newline-separated) by <text>, submitted as the session's first message. The spawned agent claims its identity and acts on the task in the same first turn — no monitor/bridge needed.

The prompt flows through both launch paths unchanged in shape:

  • direct-CLI types: passed as the single positional initial-prompt argument.
  • node-launcher types: passed via the existing --initial-input flag.

printf '%q' in the boot-script block escapes the embedded newline (as $'\n'), so the whole multi-line prompt reaches the CLI as one argument.

Backward compatibility

With no --prompt, ACTAS_PROMPT is untouched and the generated boot script is byte-for-byte identical to before. The new option slots into the existing case parse loop and uses the same ${2:?...} missing-arg guard as the other value-taking options.

Usage

/agmsg spawn codex reviewer --prompt "review the diff on this branch and report blockers"

The new codex agent joins as reviewer and immediately starts the review in its first turn.

Validation

  • bash -n scripts/spawn.sh — passes.
  • shellcheck scripts/spawn.sh — no new warnings introduced (the 3 pre-existing SC2034/SC2016 notices are unchanged before/after this diff).

Docs: updated the spawn section of README.md (example + options list + a paragraph on the codex one-shot use case).

Eotel added 3 commits June 24, 2026 12:36
Add an optional --prompt <text> to spawn.sh. When provided, the boot
prompt becomes the existing actas slash command followed (newline-
separated) by <text>, so the spawned agent claims its identity AND acts
on the task in the same first turn.

This is the only way to hand a one-shot goal to a codex peer: codex has
no Monitor (docs/codex-monitor-beta.md), so a message sent after spawn
is never noticed by the now-idle session. Carrying the task in the boot
prompt sidesteps that with no monitor/bridge needed.

With no --prompt, behavior is byte-for-byte unchanged.

Claude-Session: https://claude.ai/code/session_01JD5uF5Z9Y1cydABGDFwCbA
Add two bats tests for the new --prompt flag:
  - with --prompt, the generated boot script contains the actas command
    AND the task text;
  - without --prompt, the boot script carries no extra task text (guards
    the byte-identical claim).

Also surface --prompt in the top-of-file usage synopsis, matching how the
options block already documents it.

Claude-Session: https://claude.ai/code/session_01JD5uF5Z9Y1cydABGDFwCbA
Complements 21d6a2f (claude-code folding + backward-compat tests) on this
branch. Adds the coverage it didn't:
  - codex folding: the task lands in a spawned codex's first prompt too —
    the no-Monitor case --prompt exists for;
  - the missing-arg guard;
  - `--prompt ""` as a no-op.

Also fix `--prompt ""`: the parser used ${2:?...}, which rejects an explicit
empty string and contradicts the existing `[ -n "$PROMPT" ]` no-op guard.
Switch to ${2?...} so a MISSING arg still errors but an empty string degrades
to a plain spawn (e.g. a scripted `--prompt "$VAR"` with an empty VAR).

Document --prompt in SKILL.md (the agent-facing command surface) and llms.txt;
the prior commits only updated README + the spawn.sh synopsis/options.
@Eotel Eotel marked this pull request as ready for review June 24, 2026 06:36
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