You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(claude): keep a positional prompt from being read as a variadic flag's value - #48082
When Orca starts Claude with a prompt, it puts the prompt at the end of the command line. Some Claude options are greedy: --disallowedTools Agent keeps taking words after it, so it took the prompt too and Claude opened with an empty box. Orca now puts a -- between Claude's options and the prompt, so the prompt can't be taken.
What Changed
Before: with Claude default args --permission-mode auto --disallowedTools Agent, a launch with a prompt ran
claude '--permission-mode' 'auto' '--disallowedTools' 'Agent' 'Reply OK'
--disallowedTools is variadic, so Claude read Reply OK as a tool name, printed a "Deny rule ... matches no tool" warning and sat idle. The launch still reported success.
After:
claude '--permission-mode' 'auto' '--disallowedTools' 'Agent' '--' 'Reply OK'
Mechanism:
tui-agent-config.ts: Claude now sets argvPromptSeparator: '--', the same setting Grok and other argv agents already use.
New argv-prompt-separator.ts: argvPromptSeparator() decides what goes between the launch command and the prompt:
No separator when the agent's own options already end with a real --. A second -- would become the prompt. The check reuses agentArgTerminatorIndex, so a -- that is an option's value (--append-system-prompt --) does not count.
For Claude it reads the tokens after the claude executable in the resolved launch command (findClaudeExecutableIndex). A wrapper's own -- (mise exec -- claude) is therefore not treated as Claude's.
When a Claude command override is not literally claude (for example Happy, which adds --settings <hooks.json> after the forwarded args), no separator is added. A -- there would turn Happy's flags into the prompt.
The separator is quoted with quoteStartupArg. PowerShell drops a bare -- before a function or .ps1 shim sees $args.
tui-agent-startup.ts: the argv branch calls argvPromptSeparator() instead of adding the config value as-is.
Why
Claude adds the prompt as a bare operand, so any variadic flag at the end of the default args takes it, and the user gets no error. -- is the standard end-of-options marker, and it keeps working as new variadic flags are added. A separate table of variadic Claude flags would have to be kept up to date. The guards keep -- out of the cases where it would break the launch: options that already ended, and wrappers that add their own flags.
N/A. Nothing changes in the UI. The difference is the argv Orca builds. The unit tests check the exact launch strings, and a real Claude CLI run was checked (see Testing).
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
New src/shared/agent-launch/startup/tui-agent-startup.test.ts covers 6 cases: a trailing variadic flag, PowerShell and cmd quoting, args that already end with --, a -- that is an option value, a -- inside a wrapper override (Grok and Claude), and the Happy wrapper. Reverting only the source files to main fails the 4 behaviour tests. The 2 guard tests (no double --, no separator for Happy) pass both ways, as intended.
vitest run src/shared/agent-launch: 22/22 pass.
Claude CLI 2.1.331 on macOS: claude -p --disallowedTools Agent -- 'Reply with only the word OK.' answers OK, so Claude reads the prompt after -- as an operand.
Clean on the changed files: oxlint (default, anti-slop and code-quality configs), ast-grep, oxfmt, and the changed-code quality gate.
Platforms: macOS (unit tests and the real CLI run). Windows PowerShell and cmd are covered by the quoting tests.
Performance
None that matters: this runs once per agent launch, does no I/O and starts no subprocess. Measured buildAgentStartupPlan (posix, mean of 20k runs):
case
main
this PR
typical Claude args
3.2 µs
4.5 µs
empty Claude args
0.69 µs
1.15 µs
mise exec -- claude override
1.6 µs
2.4 µs
Grok, no args
0.53 µs
0.68 µs
adversarial: 500 --add-dir flags
455 µs
595 µs
Risk
Level: Low
Claude launches with a prompt now always get '--' before the prompt, unless the options already ended or the override is a wrapper that isn't claude. Claude's own parser accepts this (checked above).
Agents that already had argvPromptSeparator: '--' now get it quoted. On POSIX and cmd the argv is the same. On PowerShell the -- now reaches function and .ps1 shims, where before it was dropped. They also skip the separator when their args already end with --, where before the second -- became the prompt.
Nothing is saved or synced. Back out with a plain revert.
Review
Covered: cross-platform quoting (POSIX, PowerShell, cmd), wrapper overrides, and options that already ended. Nothing changes for SSH or remote: the launch string is built the same way as before, on the same host.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Argv-mode startup now determines the prompt separator from the agent, launch command, agent arguments, and shell. Claude is configured to use --. The separator is omitted when the parsed arguments already contain a terminator. Tests cover POSIX, PowerShell, and cmd behavior, including command overrides and option values.
Severity of issue fixed: Medium
Merge Risk: Low · up to 5fe53
The change inserts -- before the prompt for Claude launches so variadic options no longer swallow it. A rare case, where a user passes --prefill --, can still leave the prompt consumed. This is a small follow-up rather than a merge blocker.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the Claude-specific fix: a positional prompt being consumed as the value of a variadic flag. The changeset adds a -- terminator before the prompt when Claude's launch args end with a…
Description check
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #48072), Visual Proof (N/A with reason), Testing, Performance, Risk (Level: Low), AI Disclo…
Linked Issues check
[#48072] Requires that a Claude launch whose args end in an open variadic option still delivers the positional prompt. At the reviewed head, buildAgentStartupPlan calls argvPromptSeparator (argv-promp…
Out of Scope Changes check
The whole-PR changes are tui-agent-startup.ts (one call site change), the new argv-prompt-separator.ts, tui-agent-config.ts (claude argvPromptSeparator '--'), and tui-agent-startup.test.ts. All of the…
Full details: Title check
Explanation
The title names the Claude-specific fix: a positional prompt being consumed as the value of a variadic flag. The changeset adds a -- terminator before the prompt when Claude's launch args end with an open variadic option, which matches the title's subject. The title is 80 characters and 13 words, a little long, but it is specific and conveys the primary change.
Full details: Description check
Explanation
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #48072), Visual Proof (N/A with reason), Testing, Performance, Risk (Level: Low), AI Disclosure, Review, and Checklist sections. The before/after is concrete, the mechanism is explained, and the alternatives are discussed. Minor gaps: the Risk section names a level but the template's 'Level' line is filled in, and the Agent skill upstream boundary section is checked as not applicable. The Testing section states the platform (macOS, Node 24, posix). The description is substantially complete.
Full details: Linked Issues check
Explanation
[#48072] Requires that a Claude launch whose args end in an open variadic option still delivers the positional prompt. At the reviewed head, buildAgentStartupPlan calls argvPromptSeparator (argv-prompt-separator.ts) in argv mode. For agent 'claude', that function tokenizes the launch command, locates the Claude executable with findClaudeExecutableIndex, and returns the args after it. It returns ' --' unless the args already contain a terminator (agentArgTerminatorIndex). The config (tui-agent-config.ts) sets claude's argvPromptSeparator to '--'. So a Claude argv launch with the issue's args (--permission-mode auto --disallowedTools Agent) gets ' --' before the prompt, and the prompt is not consumed. An existing '--' is not duplicated. The issue's workarounds also remain valid with a separator. The previous assessment cited claudeArgvTerminator and claudeArgsEndWithOpenVariadicOption; those names do not match the reviewed head. This verdict uses the current head's argvPromptSeparator. Test content was not read, so test claims are unverified. The Settings warning in the issue is optional and is not implemented.
Full details: Out of Scope Changes check
Explanation
The whole-PR changes are tui-agent-startup.ts (one call site change), the new argv-prompt-separator.ts, tui-agent-config.ts (claude argvPromptSeparator '--'), and tui-agent-startup.test.ts. All of them serve the prompt-separator fix for [#48072]. They do not change unrelated agent behavior: the non-claude path uses agentArgs tokens and the same terminator check. Discrepancy: the PR description says only Claude launches with an open variadic tail change, and non-variadic tails are byte-identical. At head, every Claude argv launch without an existing terminator gets ' --', including tails with no variadic option. This is broader than the description states. It is still tied to the same positional-prompt defect, so it is not an unrelated change. Residual risk: the description says ' --' breaks subcommand resolution. Claude launches whose args include a subcommand now receive ' --' too. I did not run or inspect those cases. The test file was not read.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
claudeArgvTerminator now locates the executable with the existing findClaudeExecutableIndex helper and reads only the arguments that follow it, so env -- claude no longer lets the wrapper's -- end the scan. When no executable token can be identified (a shim under some other name) it keeps the previous read of everything after token 0 — dropping the terminator there would regress the case the original commit fixed.
Two new tests, and the wrapper one fails without the change:
ignores a terminator that belongs to a wrapper command — now yields env -- claude '--disallowedTools' 'Agent' -- '<prompt>'
still separates the prompt when no Claude token can be identified — pins the fallback
10/10 in tui-agent-startup.test.ts, pnpm tc green.
…lag's value
Claude default args ending in a variadic flag (`--disallowedTools Agent`)
swallowed the argv launch prompt as that flag's value, so the session started
empty. Claude launches now put `--` before the prompt unless the agent's own
options already end with one; a non-claude override wrapper (Happy) gets no
separator since it appends its own flags after the forwarded args. The
separator is quoted so PowerShell functions and .ps1 shims forward it.
Fixesstablyai#48072
Co-authored-by: 2SinceJuly <[email protected]>
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Add --prefill to the Claude required-value options.
--prefill takes a text operand, so a following -- is its value, not a terminator. The required-value table omits --prefill, so agentArgTerminatorIndex treats that -- as the end of options. argvPromptSeparator then returns an empty string, and the startup prompt can follow an open --disallowedTools option. The same failure described in the PR can then occur. Add --prefill to the Claude list in AGENT_REQUIRED_VALUE_OPTIONS, and cover this case in tui-agent-startup.test.ts.
--prefill <text> takes an operand (it is in the CLI's own dash-consuming set alongside --settings, --model and --session-id), so a following -- seeds the draft input rather than ending options. Without it in the required-value table, agentArgTerminatorIndex found that -- and reported option parsing as already over, argvPromptSeparator returned an empty string, and the startup prompt could then land as the value of an open variadic flag such as --disallowedTools.
--prefill is now in the Claude required-value list, with a case in tui-agent-startup.test.ts that fails without it:
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
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.
ELI5
When Orca starts Claude with a prompt, it puts the prompt at the end of the command line. Some Claude options are greedy:
--disallowedTools Agentkeeps taking words after it, so it took the prompt too and Claude opened with an empty box. Orca now puts a--between Claude's options and the prompt, so the prompt can't be taken.What Changed
Before: with Claude default args
--permission-mode auto --disallowedTools Agent, a launch with a prompt ran--disallowedToolsis variadic, so Claude readReply OKas a tool name, printed a "Deny rule ... matches no tool" warning and sat idle. The launch still reported success.After:
Mechanism:
tui-agent-config.ts: Claude now setsargvPromptSeparator: '--', the same setting Grok and other argv agents already use.argv-prompt-separator.ts:argvPromptSeparator()decides what goes between the launch command and the prompt:--. A second--would become the prompt. The check reusesagentArgTerminatorIndex, so a--that is an option's value (--append-system-prompt --) does not count.claudeexecutable in the resolved launch command (findClaudeExecutableIndex). A wrapper's own--(mise exec -- claude) is therefore not treated as Claude's.claude(for example Happy, which adds--settings <hooks.json>after the forwarded args), no separator is added. A--there would turn Happy's flags into the prompt.quoteStartupArg. PowerShell drops a bare--before a function or.ps1shim sees$args.tui-agent-startup.ts: the argv branch callsargvPromptSeparator()instead of adding the config value as-is.Why
Claude adds the prompt as a bare operand, so any variadic flag at the end of the default args takes it, and the user gets no error.
--is the standard end-of-options marker, and it keeps working as new variadic flags are added. A separate table of variadic Claude flags would have to be kept up to date. The guards keep--out of the cases where it would break the launch: options that already ended, and wrappers that add their own flags.Original fix by @2SinceJuly in #48082.
Linked Issue
Fixes #48072
Visual Proof
N/A. Nothing changes in the UI. The difference is the argv Orca builds. The unit tests check the exact launch strings, and a real Claude CLI run was checked (see Testing).
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
New
src/shared/agent-launch/startup/tui-agent-startup.test.tscovers 6 cases: a trailing variadic flag, PowerShell and cmd quoting, args that already end with--, a--that is an option value, a--inside a wrapper override (Grok and Claude), and the Happy wrapper. Reverting only the source files tomainfails the 4 behaviour tests. The 2 guard tests (no double--, no separator for Happy) pass both ways, as intended.vitest run src/shared/agent-launch: 22/22 pass.Claude CLI 2.1.331 on macOS:
claude -p --disallowedTools Agent -- 'Reply with only the word OK.'answersOK, so Claude reads the prompt after--as an operand.Clean on the changed files: oxlint (default, anti-slop and code-quality configs), ast-grep, oxfmt, and the changed-code quality gate.
Platforms: macOS (unit tests and the real CLI run). Windows PowerShell and cmd are covered by the quoting tests.
Performance
None that matters: this runs once per agent launch, does no I/O and starts no subprocess. Measured
buildAgentStartupPlan(posix, mean of 20k runs):mise exec -- claudeoverride--add-dirflagsRisk
Level: Low
'--'before the prompt, unless the options already ended or the override is a wrapper that isn'tclaude. Claude's own parser accepts this (checked above).argvPromptSeparator: '--'now get it quoted. On POSIX and cmd the argv is the same. On PowerShell the--now reaches function and.ps1shims, where before it was dropped. They also skip the separator when their args already end with--, where before the second--became the prompt.Review
Covered: cross-platform quoting (POSIX, PowerShell, cmd), wrapper overrides, and options that already ended. Nothing changes for SSH or remote: the launch string is built the same way as before, on the same host.
Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)