feat(spawn): allow passing an initial prompt to the spawned agent#212
Open
Eotel wants to merge 3 commits into
Open
feat(spawn): allow passing an initial prompt to the spawned agent#212Eotel wants to merge 3 commits into
Eotel wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
spawn.shboots 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 (seedocs/codex-monitor-beta.md) — so a message yousendafter 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>tospawn.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:
--initial-inputflag.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_PROMPTis untouched and the generated boot script is byte-for-byte identical to before. The new option slots into the existingcaseparse loop and uses the same${2:?...}missing-arg guard as the other value-taking options.Usage
The new codex agent joins as
reviewerand 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
spawnsection ofREADME.md(example + options list + a paragraph on the codex one-shot use case).