Skip to content

fix(claude): keep a positional prompt from being read as a variadic flag's value - #48082

Merged
nwparker merged 1 commit into
stablyai:mainfrom
2SinceJuly:fix/48072-claude-argv-prompt-terminator
Nov 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
2SinceJuly:fix/48072-claude-argv-prompt-terminator

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 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.

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.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)

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed [#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 Passed 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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50dc7dd1-ff4b-4bb0-b607-102677a9cb70
Commits

Reviewing files that changed from the base of the PR and between 6ed63da and 318a52a.

Files selected for processing: 3

  • src/shared/agent-launch/startup/tui-agent-startup.test.ts
  • src/shared/agent-launch/startup/tui-agent-startup.ts
  • src/shared/agent-status/title/claude-cli-option-grammar.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Valid, and fixed in 973eaeb7513.

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.

Fixes stablyai#48072

Co-authored-by: 2SinceJuly <[email protected]>
@nwparker
nwparker force-pushed the fix/48072-claude-argv-prompt-terminator branch from 973eaeb to 5fe538e Compare November 24, 2026 06:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ee22cc5-968c-4e27-9896-fe859d4ce7d6
Commits

Reviewing files that changed from the base of the PR and between 973eaeb and 5fe538e.

Files selected for processing: 4

  • src/shared/agent-launch/catalog/tui-agent-config.ts
  • src/shared/agent-launch/startup/argv-prompt-separator.ts
  • src/shared/agent-launch/startup/tui-agent-startup.test.ts
  • src/shared/agent-launch/startup/tui-agent-startup.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

// Why: once options have ended, a second `--` becomes the prompt. A wrapper's own `--`
// (`mise exec -- grok`) does not end the agent's options.
const tokens = agentOptionTokens(agent, launchCommand, agentArgs, shell)
if (!tokens || agentArgTerminatorIndex(agent, tokens) < tokens.length) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

Suggested fix

     '--permission-prompt-tool',
+    '--prefill',
     '--plugin-dir',

@nwparker
nwparker merged commit 907b43c into stablyai:main Nov 24, 2026
57 checks passed
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Correct — fixed in 1e54ab1c7d3.

--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:

Expected: "claude '--prefill' '--' '--disallowedTools' 'Agent' '--' 'Reply OK'"
Received: "claude '--prefill' '--' '--disallowedTools' 'Agent' 'Reply OK'"

saltyfireball added a commit to saltyfireball/orca that referenced this pull request Nov 25, 2026
… a positional prompt

Upstream (stablyai#48082) puts -- before the prompt so a variadic flag does not take it as a value.

Co-Authored-By: Claude Code.
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.

[Bug]: --prompt swallowed when Claude default args end in a variadic flag (--disallowedTools)

2 participants