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
This commit is contained in:
Lukas May
2026-02-02 10:38:10 +01:00
parent 3c98dbe541
commit 5605547aea

View File

@@ -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