Skip to content

[Go] Anthropic: structured output conformance fails — response is not valid JSON #4692

@yesudeep

Description

@yesudeep

Summary

The Go Anthropic plugin fails structured output conformance tests. When JSON output format is requested, the model response is not valid JSON:

model failed to generate output matching expected schema: message is not a valid JSON

This affects all Anthropic models that support structured output (claude-sonnet-4-5, claude-haiku-4-5, claude-opus-4-6) for both streaming and non-streaming requests.

Expected behavior

When output.format = "json" is requested with a JSON schema, the Go Anthropic plugin should pass the output schema to the Anthropic API (e.g. via response_format or tool-based extraction) so the model returns valid JSON matching the schema.

Reproduction

cd py && bin/conform check-model anthropic --runtime go --runner native

Look for "Structured Output Conformance" failures.

Affected models

  • anthropic/claude-sonnet-4-5 — Structured Output (streaming + non-streaming)
  • anthropic/claude-haiku-4-5 — Structured Output (streaming + non-streaming)
  • anthropic/claude-opus-4-6 — Structured Output (streaming + non-streaming)

Notes

The Python Anthropic plugin handles this correctly by passing the JSON schema constraint to the API. The Go plugin likely needs to implement the same schema-passing mechanism.

Metadata

Metadata

Assignees

Labels

featureNew feature or requestgo

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions