Compare commits

...

3 Commits

Author SHA1 Message Date
Ashwin Bhat
5940655715 Default systemPrompt to claude_code preset
Without an explicit systemPrompt, the SDK would use no system prompt.
Now it defaults to the claude_code preset to match CLI behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 16:21:16 -08:00
Ashwin Bhat
0c4374199a Add settingSources to SDK options to load plugins
Without settingSources, the SDK doesn't load any filesystem settings,
which means plugins installed via CLI aren't available. Adding
settingSources: ['user', 'project', 'local'] ensures CLI-installed
plugins and CLAUDE.md files are loaded.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 16:20:33 -08:00
Ashwin Bhat
c67fb66a79 Add debug logging to Agent SDK path
Temporary debugging to investigate SDK behavior in CI:
- Log raw and parsed options
- Log prompt content and length
- Log each message received from query()
- Log final result message

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 16:09:03 -08:00
3 changed files with 42 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
env.GITHUB_ACTION_INPUTS = process.env.INPUT_ACTION_INPUTS_PRESENT; env.GITHUB_ACTION_INPUTS = process.env.INPUT_ACTION_INPUTS_PRESENT;
} }
// Build system prompt option // Build system prompt option - default to claude_code preset
let systemPrompt: SdkOptions["systemPrompt"]; let systemPrompt: SdkOptions["systemPrompt"];
if (options.systemPrompt) { if (options.systemPrompt) {
systemPrompt = options.systemPrompt; systemPrompt = options.systemPrompt;
@@ -111,6 +111,12 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
preset: "claude_code", preset: "claude_code",
append: options.appendSystemPrompt, append: options.appendSystemPrompt,
}; };
} else {
// Default to claude_code preset when no custom prompt is specified
systemPrompt = {
type: "preset",
preset: "claude_code",
};
} }
// Build SDK options - use merged tools from both direct options and claudeArgs // Build SDK options - use merged tools from both direct options and claudeArgs
@@ -130,6 +136,9 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions {
// Note: allowedTools and disallowedTools have been removed from extraArgs to prevent duplicates // Note: allowedTools and disallowedTools have been removed from extraArgs to prevent duplicates
extraArgs, extraArgs,
env, env,
// Load settings from all sources to pick up CLI-installed plugins, CLAUDE.md, etc.
settingSources: ["user", "project", "local"],
}; };
return { return {

View File

@@ -75,12 +75,28 @@ export async function runClaudeWithSdk(
} }
console.log(`Running Claude with prompt from file: ${promptPath}`); console.log(`Running Claude with prompt from file: ${promptPath}`);
console.log(
"[DEBUG] Prompt content (first 2000 chars):",
prompt.substring(0, 2000),
);
console.log("[DEBUG] Prompt length:", prompt.length);
console.log(
"[DEBUG] sdkOptions passed to query():",
JSON.stringify(sdkOptions, null, 2),
);
const messages: SDKMessage[] = []; const messages: SDKMessage[] = [];
let resultMessage: SDKResultMessage | undefined; let resultMessage: SDKResultMessage | undefined;
try { try {
console.log("[DEBUG] About to call query()...");
for await (const message of query({ prompt, options: sdkOptions })) { for await (const message of query({ prompt, options: sdkOptions })) {
console.log(
"[DEBUG] Received message type:",
message.type,
"subtype:",
(message as any).subtype,
);
messages.push(message); messages.push(message);
const sanitized = sanitizeSdkOutput(message, showFullOutput); const sanitized = sanitizeSdkOutput(message, showFullOutput);
@@ -90,8 +106,16 @@ export async function runClaudeWithSdk(
if (message.type === "result") { if (message.type === "result") {
resultMessage = message as SDKResultMessage; resultMessage = message as SDKResultMessage;
console.log(
"[DEBUG] Got result message:",
JSON.stringify(resultMessage, null, 2),
);
} }
} }
console.log(
"[DEBUG] Finished iterating query(), total messages:",
messages.length,
);
} catch (error) { } catch (error) {
console.error("SDK execution error:", error); console.error("SDK execution error:", error);
core.setOutput("conclusion", "failure"); core.setOutput("conclusion", "failure");

View File

@@ -174,7 +174,15 @@ export async function runClaude(promptPath: string, options: ClaudeOptions) {
); );
if (useAgentSdk) { if (useAgentSdk) {
console.log(
"[DEBUG] Raw options passed to SDK path:",
JSON.stringify(options, null, 2),
);
const parsedOptions = parseSdkOptions(options); const parsedOptions = parseSdkOptions(options);
console.log(
"[DEBUG] Parsed SDK options:",
JSON.stringify(parsedOptions, null, 2),
);
return runClaudeWithSdk(promptPath, parsedOptions); return runClaudeWithSdk(promptPath, parsedOptions);
} }