Skip to content

Commit a7e81a8

Browse files
steveyeggeRandom-Wordclaude
committed
fix: witness buildWitnessStartCommand had same non-Claude agent bug as daemon
The daemon getStartCommand was already fixed (GH#2417) to skip the TOML start_command for non-Claude agents, but the identical logic in witness buildWitnessStartCommand was missed. Non-Claude witness agents still hit the hardcoded exec claude TOML path, causing exit 127. Apply the same if/else-if pattern used in the daemon fix. Closes #2925 Co-Authored-By: Ross Story <Random-Word@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0e964b2 commit a7e81a8

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

internal/witness/manager.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,15 @@ func buildWitnessStartCommand(rigPath, rigName, townRoot, sessionName, agentOver
309309
roleConfig = nil
310310
}
311311
if roleConfig != nil && roleConfig.StartCommand != "" {
312-
// Use the TOML start_command for custom (non-Claude) commands that
313-
// need template expansion (e.g., "exec run --town {town} --rig {rig}").
314-
// For Claude agents, skip the TOML shortcut and fall through to
315-
// BuildStartupCommandFromConfig which resolves model flags from
316-
// role_agents (e.g., --model sonnet[1m]). The built-in TOML
317-
// start_command ("exec claude --dangerously-skip-permissions") strips
318-
// these flags, breaking per-role model selection.
319312
rc := config.ResolveRoleAgentConfig("witness", townRoot, rigPath)
320-
if !config.IsResolvedAgentClaude(rc) || !isBuiltinClaudeStartCommand(roleConfig.StartCommand) {
321-
// Non-Claude agent OR custom start_command: use TOML pattern
322-
// with template expansion.
313+
if !config.IsResolvedAgentClaude(rc) {
314+
// Non-Claude agent: skip TOML start_command entirely.
315+
// Built-in role TOMLs hardcode "exec claude ..." which is wrong
316+
// for non-Claude agents. Fall through to BuildStartupCommandFromConfig
317+
// which uses the resolved agent's command and args.
318+
} else if !isBuiltinClaudeStartCommand(roleConfig.StartCommand) {
319+
// Custom (non-builtin) start_command with Claude agent: use TOML
320+
// pattern with template expansion.
323321
cmd := beads.ExpandRolePattern(roleConfig.StartCommand, townRoot, rigName, "", "witness", session.PrefixFor(rigName))
324322
if strings.HasPrefix(cmd, "exec ") {
325323
cmd = "exec env -u CLAUDECODE NODE_OPTIONS='' " + strings.TrimPrefix(cmd, "exec ")
@@ -328,8 +326,9 @@ func buildWitnessStartCommand(rigPath, rigName, townRoot, sessionName, agentOver
328326
}
329327
return cmd, nil
330328
}
331-
// Claude agent with built-in start_command: fall through to
332-
// BuildStartupCommandFromConfig for proper model flag resolution.
329+
// Non-Claude agent OR Claude with built-in start_command: fall
330+
// through to BuildStartupCommandFromConfig for proper agent and
331+
// model flag resolution.
333332
}
334333
initialPrompt := session.BuildStartupPrompt(session.BeaconConfig{
335334
Recipient: session.BeaconRecipient("witness", "", rigName),

0 commit comments

Comments
 (0)