From 5605547aea3582441d9c83517bb506de12c14f8e Mon Sep 17 00:00:00 2001 From: Lukas May Date: Mon, 2 Feb 2026 10:38:10 +0100 Subject: [PATCH] fix(13-01): parse structured_output from Claude CLI response - Add structured_output field to ClaudeCliResult interface - Read from structured_output when present (--json-schema response) - Fall back to parsing result for backwards compatibility --- src/agent/manager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/agent/manager.ts b/src/agent/manager.ts index b25a26e..ca70ccd 100644 --- a/src/agent/manager.ts +++ b/src/agent/manager.ts @@ -39,6 +39,9 @@ import { /** * Result structure from Claude CLI with --output-format json + * + * When --json-schema is used, structured output is in `structured_output` field. + * The `result` field may be empty or contain the raw text. */ interface ClaudeCliResult { type: 'result'; @@ -46,6 +49,7 @@ interface ClaudeCliResult { is_error: boolean; session_id: string; result: string; + structured_output?: unknown; // Present when --json-schema is used total_cost_usd?: number; } @@ -187,7 +191,9 @@ export class ClaudeAgentManager implements AgentManager { await this.repository.updateSessionId(agentId, cliResult.session_id); } - const rawOutput = JSON.parse(cliResult.result); + // When --json-schema is used, structured output is in structured_output field + // Falls back to parsing result if structured_output is not present (backwards compatible) + const rawOutput = cliResult.structured_output ?? JSON.parse(cliResult.result); const active = this.activeAgents.get(agentId); // Parse output based on agent mode