From d708f099be65033fa73488fbdd23a84ac05eff96 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 8 May 2026 15:25:57 +0700 Subject: [PATCH] fix(claude-agent): don't fail-fast in buildOptions resolveClaudeBinary threw eagerly inside buildOptions, breaking unit tests that mock the SDK at the module level (env, redesign, interrupt-restart- regression suites). The user-facing fail-fast already lives in isAvailable(); in buildOptions, fall back to omitting pathToClaudeCodeExecutable so the SDK surfaces its own error if the binary truly is missing. --- .../src/server/agent/providers/claude-agent.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/server/src/server/agent/providers/claude-agent.ts b/packages/server/src/server/agent/providers/claude-agent.ts index 74dd8805f..8145ea035 100644 --- a/packages/server/src/server/agent/providers/claude-agent.ts +++ b/packages/server/src/server/agent/providers/claude-agent.ts @@ -1381,16 +1381,6 @@ export class ClaudeAgentClient implements AgentClient { } } -async function resolveClaudeBinary(): Promise { - const found = await findExecutable("claude"); - if (found) { - return found; - } - throw new Error( - "Claude binary not found. Install Claude Code (https://github.com/anthropics/claude-code) and ensure it is available in your shell PATH.", - ); -} - async function resolveClaudeVersion( runtimeSettings?: ProviderRuntimeSettings, ): Promise { @@ -2293,7 +2283,7 @@ class ClaudeAgentSession implements AgentSession { ], }); - const claudeBinary = await resolveClaudeBinary(); + const claudeBinary = await findExecutable("claude"); this.logger.debug( { claudeBinary, @@ -2314,7 +2304,7 @@ class ClaudeAgentSession implements AgentSession { allowDangerouslySkipPermissions: true, agents: this.defaults?.agents, canUseTool: this.handlePermissionRequest, - pathToClaudeCodeExecutable: claudeBinary, + ...(claudeBinary ? { pathToClaudeCodeExecutable: claudeBinary } : {}), // Use Claude Code preset system prompt and load CLAUDE.md files // Append provider-agnostic system prompt and orchestrator instructions for agents. systemPrompt: {