Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(custom-agents): claude-base agents use positional prompt, not --prompt

Darren Kattan6b05587ceb94
diff --git a/src/renderer/components/settings/sections/CustomAgentsSection.tsx b/src/renderer/components/settings/sections/CustomAgentsSection.tsx
index 0335b32e9..698319c78 100644
--- a/src/renderer/components/settings/sections/CustomAgentsSection.tsx
+++ b/src/renderer/components/settings/sections/CustomAgentsSection.tsx
@@ -171,10 +171,17 @@ function AgentCard({
/>
<FieldRow
label="Prompt injection"
- description={base ? `Inherited from ${base.label}.` : undefined}
+ description={
+ base
+ ? `Inherited from ${base.label} — the prompt grammar is a property of the harness, not a preference (claude takes a positional, never --prompt).`
+ : 'How an initial prompt is passed to the CLI.'
+ }
control={
<Select
- value={agent.promptInjectionMode ?? 'argv'}
+ // Show the RESOLVED mode: when a base harness is set, its grammar wins over any stale
+ // value on the record (claude rejects --prompt), so the dropdown reflects what actually
+ // runs rather than a greyed-out wrong value.
+ value={base ? base.promptInjectionMode : agent.promptInjectionMode ?? 'argv'}
disabled={!!base}
onChange={(e) =>
onPatch(agent.id, { promptInjectionMode: e.target.value as PromptInjectionMode })
diff --git a/src/shared/agents/custom-agent.test.ts b/src/shared/agents/custom-agent.test.ts
index 61f59c2b9..dc45e9784 100644
--- a/src/shared/agents/custom-agent.test.ts
+++ b/src/shared/agents/custom-agent.test.ts
@@ -74,6 +74,28 @@ describe('resolveAgentConfig — custom with a base harness', () => {
expect(c.expectedProcess).toBe('claude')
expect(c.baseAgent).toBe('claude')
})
+ it('ignores a stale flag-prompt on a claude-base agent (claude takes a positional, not --prompt)', () => {
+ const stale: CustomAgent = {
+ id: 'custom:stale',
+ label: 'Stale',
+ launchCmd: 'claude-wopr',
+ baseAgent: 'claude',
+ promptInjectionMode: 'flag-prompt'
+ }
+ // The prompt grammar is the harness's, not the record's: claude rejects `--prompt`, so a
+ // stale flag-prompt must NOT win over the base's `argv`.
+ expect(resolveAgentConfig('custom:stale', stale).promptInjectionMode).toBe('argv')
+ })
+ it('a baseless custom agent keeps its own promptInjectionMode', () => {
+ expect(resolveAgentConfig('custom:aider', vanilla).promptInjectionMode).toBe('argv')
+ const flagPrompt: CustomAgent = {
+ id: 'custom:fp',
+ label: 'FP',
+ launchCmd: 'opencode',
+ promptInjectionMode: 'flag-prompt'
+ }
+ expect(resolveAgentConfig('custom:fp', flagPrompt).promptInjectionMode).toBe('flag-prompt')
+ })
it('inherits color from the base when the custom record has none', () => {
expect(resolveAgentConfig('custom:proxy', claudeProxy).color).toBe('#d97757')
})
diff --git a/src/shared/agents/custom-agent.ts b/src/shared/agents/custom-agent.ts
index db89b5301..8568a927c 100644
--- a/src/shared/agents/custom-agent.ts
+++ b/src/shared/agents/custom-agent.ts
@@ -42,7 +42,9 @@ export interface EffectiveAgentConfig {
* from settings); fields inherit from `baseAgent` and the custom record overrides:
* - `launchCmd`: custom value, else the base harness's command (so a claude-compatible proxy with
* a blank command runs `claude`), else the id itself (today's fallback for vanilla customs).
- * - `promptInjectionMode`: custom value, else the base's, else `argv`.
+ * - `promptInjectionMode`: from the BASE harness when `baseAgent` is set (the prompt grammar is
+ * a property of the harness — a claude wrapper takes a positional, never `--prompt`), else the
+ * custom value, else `argv`.
* - `color`: custom value, else the base's, else the fallback grey.
* - `argvPromptSeparator` / `expectedProcess`: from the base only (a custom record does not set
* these — inheriting them is the whole point of declaring a base).
@@ -57,8 +59,16 @@ export function resolveAgentConfig(
}
const base = customAgent?.baseAgent ? AGENT_CONFIG[customAgent.baseAgent] : undefined
const launchCmd = customAgent?.launchCmd?.trim() || base?.launchCmd || id
+ // The prompt grammar is a property of the HARNESS, not a user preference: `flag-prompt`
+ // (emitting `--prompt <p>`) is opencode-specific — claude/codex/grok take a POSITIONAL (`argv`)
+ // and gemini uses `stdin-after-start`. A custom agent wrapping claude (e.g. claude-wopr) speaks
+ // claude's positional grammar, so a stale `flag-prompt` on its record would emit `--prompt`,
+ // which claude rejects (`unknown option '--prompt'`). When a `baseAgent` is declared, the base's
+ // promptInjectionMode is AUTHORITATIVE and the custom record's value is ignored — exactly like
+ // `argvPromptSeparator`/`expectedProcess`, which also inherit from the base only. A baseless
+ // custom agent has no harness to inherit from, so its own value (default `argv`) stands.
const promptInjectionMode: PromptInjectionMode =
- customAgent?.promptInjectionMode ?? base?.promptInjectionMode ?? 'argv'
+ base?.promptInjectionMode ?? customAgent?.promptInjectionMode ?? 'argv'
const color = customAgent?.color || base?.color || FALLBACK_AGENT_COLOR
return {
label: customAgent?.label || id,
diff --git a/src/shared/agents/launch.test.ts b/src/shared/agents/launch.test.ts
index a7e2f90a5..0edff53e2 100644
--- a/src/shared/agents/launch.test.ts
+++ b/src/shared/agents/launch.test.ts
@@ -74,6 +74,24 @@ describe('assembleLaunchCommand — custom agents', () => {
expect(r.command).toBe("claude-wopr '--model' 'sonnet' 'fix' --permission-mode auto --session-id s1")
expect(r.missingEnv).toEqual([])
})
+ it('a claude-base agent with a stale flag-prompt emits a POSITIONAL, not --prompt', () => {
+ // Regression: a custom agent with baseAgent:'claude' + a stale promptInjectionMode:'flag-prompt'
+ // must NOT emit `--prompt` (claude rejects it). The harness's argv grammar wins.
+ setCustomAgentBaseResolver((id) => (id === 'custom:stale' ? 'claude' : undefined))
+ const stale: CustomAgent = {
+ id: 'custom:stale',
+ label: 'Stale',
+ launchCmd: 'claude-wopr',
+ baseAgent: 'claude',
+ promptInjectionMode: 'flag-prompt'
+ }
+ const r = assembleLaunchCommand(
+ { agentId: 'custom:stale', customAgent: stale, initialPrompt: 'read the handoff file' },
+ ENV
+ )
+ expect(r.command).toContain("'read the handoff file'")
+ expect(r.command).not.toContain('--prompt')
+ })
it('expands ${env:…} in args and reports missing vars', () => {
setCustomAgentBaseResolver((id) => (id === 'custom:proxy' ? 'claude' : undefined))
const r = assembleLaunchCommand(