Token-capped /ship hands its child Claude Code session its prompt (#4448) (#4452)

A `/ship` with a token cap on Claude Code no longer stops at its first
handoff: the child `claude -p` session now gets its prompt.

Why: `--allowedTools` takes every argument after it, so the prompt was
read as one more tool name and the child exited at once. The launch now
puts `--` before the prompt.

Nothing to do. Thanks to @exGeni for the report and diagnosis.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-17 16:37:56 +00:00
1 parent e0c4136dc2
commit 9c6e0a0f85
3 files changed
+31 -3

No files matched your search

@@ -0,0 +1,4 @@
---
important: blocker
---
- **A `/ship` with a token cap on Claude Code no longer stops at its first handoff.** When the budget handed steps to a fresh child, `gstack-ship-budget launch` started `claude -p` with `--allowedTools <list>` right before the prompt. Claude Code reads every argument after that option as one more tool name, so the child got no prompt, exited with "Input must be provided either through stdin or as a prompt argument", and the run stopped. The launch now ends the options with `--` before the prompt, which Claude Code 2.1.292 and 2.1.326 both read as the prompt. Thanks to @exGeni for the report and diagnosis (#4448).
+1 -1
View File
@@ -304,7 +304,7 @@ export function cmdLaunch(argv: string[], ctx: Ctx): Outcome {
const log = path.join(path.dirname(block.return_file), `child-${session}.log`);
joinMeter(block.parent_ledger, session, ctx.env);
const out = fs.openSync(log, 'a', 0o600);
const child = spawn(claude.command, [...claude.argsPrefix, '-p', '--session-id', session, ...CHILD_PERMISSION_ARGS, prompt], { cwd: ctx.cwd, env: ctx.env, detached: true, stdio: ['ignore', out, out] });
const child = spawn(claude.command, [...claude.argsPrefix, '-p', '--session-id', session, ...CHILD_PERMISSION_ARGS, '--', prompt], { cwd: ctx.cwd, env: ctx.env, detached: true, stdio: ['ignore', out, out] });
child.unref();
fs.closeSync(out);
return { stdout: [`CHILD: session=${session} pid=${child.pid} log=${log} return=${block.return_file}`], exit: 0 };
+26 -2
View File
@@ -301,6 +301,27 @@ describe('delegation', () => {
});
describe('Claude Code child launch', () => {
/**
* The argv rules of `claude --help` (2.1.292 pinned in CI, 2.1.326): a `<values...>` option takes
* every following argument up to the next one that starts with '-', and '--' ends the options.
*/
function parseLikeClaudeCli(argv: string[]): { options: Record<string, string[]>; prompts: string[] } {
const variadic = new Set(['--allowedTools', '--allowed-tools', '--disallowedTools', '--disallowed-tools', '--add-dir', '--tools']);
const valued = new Set(['--session-id', '--permission-mode', '--model', '--settings', '--output-format']);
const options: Record<string, string[]> = {};
const prompts: string[] = [];
for (let i = 0; i < argv.length; i++) {
const arg = argv[i]!;
if (arg === '--') { prompts.push(...argv.slice(i + 1)); break; }
if (variadic.has(arg)) {
const values = options[arg] ??= [];
while (i + 1 < argv.length && !argv[i + 1]!.startsWith('-')) values.push(argv[++i]!);
} else if (valued.has(arg)) options[arg] = [argv[++i]!];
else if (!arg.startsWith('-')) prompts.push(arg);
}
return { options, prompts };
}
test('launch runs the child in the background with explicit permission flags and the return file named', async () => {
const h = fresh();
const s = started(h, ['--token-cap', '80M', '--meter', 'estimate']);
@@ -314,9 +335,12 @@ describe('Claude Code child launch', () => {
const session = h.field(r.out, 'CHILD', 'session');
expect(h.field(r.out, 'CHILD', 'return')).toBe(ho.out.match(/^RETURN_FILE: (\S+)$/m)![1]!);
for (let i = 0; i < 50 && !fs.existsSync(argsFile); i++) await Bun.sleep(100);
const args = fs.readFileSync(argsFile, 'utf8').split('\n');
const args = fs.readFileSync(argsFile, 'utf8').split('\n').slice(0, -1);
expect(args.slice(0, 7)).toEqual(['-p', '--session-id', session, '--permission-mode', 'acceptEdits', '--allowedTools', 'Bash,Read,Edit,Write,Grep,Glob']);
expect(args[7]).toContain(`verify-handoff --in ${file} --session ${session}`);
const parsed = parseLikeClaudeCli(args);
expect(parsed.options['--allowedTools']).toEqual(['Bash,Read,Edit,Write,Grep,Glob']);
expect(parsed.prompts).toHaveLength(1);
expect(parsed.prompts[0]).toContain(`verify-handoff --in ${file} --session ${session}`);
});
});