Repository navigation
Fix duplicate session option flags and preserve argument values - #25382
Conversation
There was a problem hiding this comment.
Important
The production change is sound, but it leaves one existing test failing, so CI will be red until that expectation is updated.
Reviewed changes
- Suppress generated model args when the model is overridden:
resolveAgentSessionOptionLaunchno longer emitsmodelApply.launchArgswhenmodelOverridden, closing the duplicate-m/--modelcase. - Suppress model-scoped options when the model is overridden: options belonging to the picked model are now skipped when a user
-m/--modelwins, since that model's option menu may not apply. - Suppress an option's own args when that option is overridden: an option overridden by user args (e.g.
--effort low) no longer emits its configured flag; it is still dropped fromappliedValues. - Tests: new
tui-agent-launch-command-pick-flags.test.tspins single-flag output for Codex/Claude across command overrides, terminators, and shell quoting; the grok and startup expectations were updated.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughAgent argument parsing now accounts for required-value options when it finds terminators and matching flags. Launch command construction uses the selected agent’s argument rules to insert session options. Session option resolution omits picked arguments when user-supplied arguments override them. Tests cover these behaviors across agents and shell variants. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Cursor users who pass a dash-leading API key through 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
3a2f317 to
092159d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
27780955-eec7-4679-868a-3ed20aee2679
📒 Files selected for processing (16)
src/shared/agent-session-option-agent-args.tssrc/shared/agent-session-option-catalog-antigravity.tssrc/shared/agent-session-option-catalog-claude-codex.tssrc/shared/agent-session-option-catalog-codebuddy.tssrc/shared/agent-session-option-catalog-gemini-cursor.tssrc/shared/agent-session-option-catalog-grok.tssrc/shared/agent-session-option-catalog-muse.tssrc/shared/agent-session-option-catalog-omp.tssrc/shared/agent-session-option-catalog-opencode.test.tssrc/shared/agent-session-option-catalog-opencode.tssrc/shared/agent-session-option-catalog-removers.test.tssrc/shared/agent-session-option-catalog-types.tssrc/shared/command-option-occurrence.tssrc/shared/tui-agent-launch-command-argument-values.test.tssrc/shared/tui-agent-launch-command-pick-flags.test.tssrc/shared/tui-agent-launch-command.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the single commit pushed since the prior pullfrog review (3a2f317d). The core override fix in agent-session-option-launch.ts is unchanged; the delta is value-aware argument scanning plus catalog plumbing.
- Value-aware option scanning:
findOptionOccurrencenow accepts known required-value options and skips a following dash-leading token (including--), so prompt text like--model=haikustays a value instead of reading as an override.removeAgentArgOptionthreadsVALUE_OPTIONS[agent]through every catalog. - Terminator handling:
insertBeforeTerminatoruses the newagentArgTerminatorIndex, so a--that is a required option's value no longer stops worker picks from landing before the real terminator;matchesOptionno longer mistakes--=xfor--. - Catalog plumbing: each catalog identifies its agent to the matcher, and the
removeAgentArgsJSDoc reflects the widened contract. - Tests: new
tui-agent-launch-command-argument-values.test.tspins flag-like prompt values,--values, inline values, and Cursor's dash-leading--api-keyacross posix/powershell/cmd; the stale OpenCode expectation from the prior review is now{ args: [], appliedValues: {} }; the removers test covers the terminator scan.
The prior review's one thread is resolved by that OpenCode expectation update. I ran the seven touched suites locally — 135 tests pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
… and tolerate headless test doubles - v1.4.222 (stablyai#25382) drops a structured flag that raw arguments shadow, because a repeated model flag can stop the CLI starting. Three fork tests still expected the duplicated flags; their original cases now use a non-shadowing raw argument and new cases pin the shadow behaviour. - The re-homed automation dispatch seam called runtime.buildAutomationRunLaunchSettings directly, which upstream's headless orcad double does not provide; a fork helper returns null when the runtime lacks it. - The PR field generation seam replaced upstream's overrides with resolved Source Control AI params even when nothing was saved to materialize; it now does so only when the recipe carries structured launch options.
…e fork tests - The fork composer field handled paste in the bubble phase; upstream's field captures it, and non-bubbling paste events never reached the fork handler. - The terminal dock seam reads the unified tab catalog and remote ConPTY state only when they exist and the dock is on, so upstream's minimal store doubles render TerminalPaneSurface. - Two fork tests follow upstream behaviour: stablyai#25382's shadowed-flag rule, and the cancelSubscription call v1.4.224's abortable runtime calls make.

ELI5
Saved model picks and configured agent arguments could both send the same flag and stop an agent from starting. The launcher now sends the configured flag once and records only the picks it actually sends.
What Changed
-c model=o3: the command now sends the config override alone, without a competing generated-m. Tests cover the short, long, and joined forms; this does not assume which form Codex previously preferred.--model=haikuand--effort=lowremains a value. Detection, removal, and worker flag insertion share the same matching rules. A prompt value of--no longer gets mistaken for the argument terminator.Each catalog identifies its agent to the existing matcher. Known required-value options for Claude and Cursor protect their dash-leading values; boolean and optional-valued options still allow following real flags to be recognized.
Why
The existing catalogs already map model and effort aliases, including Codex config keys. Resolving conflicts before building the command works with CLIs that reject duplicate flags and keeps the launch record accurate. Parsing arbitrary custom commands would confuse wrapper flags such as Docker's
-mmemory option with agent model flags.Linked Issue
N/A — maintainer fix; no linked issue.
Visual Proof
N/A — generated CLI arguments change; regression tests assert the before/after behavior. No UI controls or layout changed.
Testing
444 focused tests passed across shared launch code, downstream command plans, worker preferences, renderer callers, and runtime startup.
POSIX, PowerShell, and cmd command generation covered on a macOS host, including flag-like values, actual overrides, terminators, and custom-command guards. Existing remote POSIX quoting coverage also passed.
pnpm tcandpnpm run check:code-quality:changedpassed. The commit hook passed oxlint, React Doctor lint, and formatting.Live native Windows/SSH agent launches were not run. Full-suite tests and packaging are left to CI.
I manually tested agent startup in the app
Automated tests added/updated
Review
Self-reviewed the shared resolver, matcher consumers, worker argument replacement, and startup callers.
Agent skill upstream boundary
Notes
Known limitation: model or effort flags inside a custom Agent Command can still conflict with picks and leave an inaccurate launch record. For example,
codex -m o3plus a pickedgpt-5.5can still emit both model flags. Custom-command handling is unchanged in this PR. A follow-up can inspect commands only when the first token is the agent's own binary, while preserving wrapper and shell commands.Checklist