Add outputFormat for structured JSON output (a2a-claude) - #33
Draft
col wants to merge 5 commits into
Draft
Conversation
…outputFormat Adds a ClaudeOutputFormat type and ClaudeConfig.outputFormat field, and threads it through buildQueryOptions to the SDK's Options.outputFormat. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a trailing structuredData? parameter to publishFinalArtifact and publishLastChunkMarker, appending a JSON data part after the text part when structuredData is a non-null, non-array object. Text-only artifacts are unaffected. Lays the groundwork for Task 4 (a2a-claude) to publish structured output alongside text. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Capture the SDK result message's structured_output on a successful turn and forward it to publishFinalArtifact / publishLastChunkMarker, which append it as a JSON data part on the response artifact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eset Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
claude.outputFormatconfig option to a2a-claude that maps 1:1 onto the Claude Agent SDK'sOptions.outputFormat, enabling structured JSON output from the Claude session, and surfaces the SDK'sstructured_outputto A2A clients.This implements the
outputFormatitem from the a2a-claude Phase 2 roadmap.What changed
claude.outputFormatconfig (a2a-claude): new optional field of shape{ "type": "json_schema", "schema": { ...JSON Schema... } }, mapped straight through to the SDK inbuildQueryOptions. Omitted → SDK default (freeform text), so behaviour is unchanged when unset.validateConfig()rejects a malformedoutputFormat(non-object,typeother than"json_schema", or a missing/non-objectschema), matching the existing hand-rolledeffort/thinkingvalidators.structured_outputis published as an additiveapplication/jsondata part on theresponseartifact, alongside the usual text part.resultis always still emitted as text, so text-only clients are unaffected.@a2a-wrapper/core:publishFinalArtifact/publishLastChunkMarkergain an optional trailingstructuredDataparameter (backward-compatible; all existing call sites unchanged) that appends the data part via a sharedresponsePartshelper.outputFormatdefinition, and a changeset is included (a2a-claudeminor,@a2a-wrapper/corepatch).SDK behaviour notes
Verified against
@anthropic-ai/claude-agent-sdk@0.3.202:Options.outputFormatis exclusively{ type: 'json_schema'; schema }. On the result message,result: stringis always present andstructured_output?: unknownis additive — so surfacing is additive rather than a replacement.Testing
@a2a-wrapper/core: full suite passes, incl. new data-part tests.a2a-claude: new tests cover the SDK mapping, validation (5 rejection + 2 accept cases), and end-to-end structured-output surfacing. All suites pass.Note
Opened as a draft pending end-to-end behaviour verification against a live Claude session.