From afd0395028e34165b4dcb3d6d462a548ecb194d8 Mon Sep 17 00:00:00 2001 From: d3oxy Date: Sat, 2 May 2026 22:53:25 +0530 Subject: [PATCH] fix(claude-agent): opt into claude_code system prompt preset Claude Agent SDK v0.1.0+ defaults to an empty system prompt; without explicitly opting into the `claude_code` preset, the agent loses the built-in tool-use guidance and environment context (cwd, OS, date, etc.) that Claude Code normally injects. As a result it had no awareness of the working directory and frequently asked for project context that it should have inferred. Pass `systemPrompt: { type: "preset", preset: "claude_code" }` to `query()` so the SDK provides the same system prompt as the Claude Code CLI. `settingSources` already includes "user", "project", "local", so CLAUDE.md continues to load on top. --- apps/server/src/provider/Layers/ClaudeAdapter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/server/src/provider/Layers/ClaudeAdapter.ts b/apps/server/src/provider/Layers/ClaudeAdapter.ts index 2fd40f6ecc5..556504d6cf4 100644 --- a/apps/server/src/provider/Layers/ClaudeAdapter.ts +++ b/apps/server/src/provider/Layers/ClaudeAdapter.ts @@ -2873,6 +2873,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( ...(input.cwd ? { cwd: input.cwd } : {}), ...(apiModelId ? { model: apiModelId } : {}), pathToClaudeCodeExecutable: claudeBinaryPath, + systemPrompt: { type: "preset", preset: "claude_code" }, settingSources: [...CLAUDE_SETTING_SOURCES], // The SDK type lags the CLI here: Opus 4.7 accepts `xhigh` even though // the published `Options["effort"]` union currently stops at `max`.