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>
This commit is contained in:
Ashwin Bhat
2025-12-06 16:09:03 -08:00
parent 6610520549
commit c67fb66a79
2 changed files with 32 additions and 0 deletions

View File

@@ -75,12 +75,28 @@ export async function runClaudeWithSdk(
}
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[] = [];
let resultMessage: SDKResultMessage | undefined;
try {
console.log("[DEBUG] About to call query()...");
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);
const sanitized = sanitizeSdkOutput(message, showFullOutput);
@@ -90,8 +106,16 @@ export async function runClaudeWithSdk(
if (message.type === "result") {
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) {
console.error("SDK execution error:", error);
core.setOutput("conclusion", "failure");

View File

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