Skip to content

Add outputFormat for structured JSON output (a2a-claude) - #33

Draft
col wants to merge 5 commits into
shashikanth-gs:mainfrom
col:feat/output-format
Draft

Add outputFormat for structured JSON output (a2a-claude)#33
col wants to merge 5 commits into
shashikanth-gs:mainfrom
col:feat/output-format

Conversation

@col

@col col commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a claude.outputFormat config option to a2a-claude that maps 1:1 onto the Claude Agent SDK's Options.outputFormat, enabling structured JSON output from the Claude session, and surfaces the SDK's structured_output to A2A clients.

This implements the outputFormat item from the a2a-claude Phase 2 roadmap.

What changed

  • claude.outputFormat config (a2a-claude): new optional field of shape { "type": "json_schema", "schema": { ...JSON Schema... } }, mapped straight through to the SDK in buildQueryOptions. Omitted → SDK default (freeform text), so behaviour is unchanged when unset.
  • Startup validation: validateConfig() rejects a malformed outputFormat (non-object, type other than "json_schema", or a missing/non-object schema), matching the existing hand-rolled effort/thinking validators.
  • Structured output surfacing: on a successful turn, the SDK result's structured_output is published as an additive application/json data part on the response artifact, alongside the usual text part. result is always still emitted as text, so text-only clients are unaffected.
  • @a2a-wrapper/core: publishFinalArtifact / publishLastChunkMarker gain an optional trailing structuredData parameter (backward-compatible; all existing call sites unchanged) that appends the data part via a shared responseParts helper.
  • Docs/metadata: README documents the option (and it's removed from the Phase 2 roadmap), the JSON schema gains the outputFormat definition, and a changeset is included (a2a-claude minor, @a2a-wrapper/core patch).

SDK behaviour notes

Verified against @anthropic-ai/claude-agent-sdk@0.3.202: Options.outputFormat is exclusively { type: 'json_schema'; schema }. On the result message, result: string is always present and structured_output?: unknown is 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.

Throng Agent and others added 5 commits August 18, 2026 06:05
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant