-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
Forgive me if this is pebac, but looking at the schema parsing logic in the SDK here:
anthropic-sdk-go/schemautil.go
Line 54 in 0e4a219
| var supportedSchemaKeys = []string{ |
enum as supported, but the docs appear to suggest they do/should: https://platform.claude.com/docs/en/build-with-claude/structured-outputs#json-schema-limitations
I was able to set them back with an inelegant workaround and it appears to work just fine (tested against anthropic API and Azure AI Anthropic API) with Haiku 4.5
...
// SDK's BetaJSONSchemaOutputFormat strips "enum" fields
// (Possible bug? enum is supported per docs but not in supportedSchemaKeys list)
// Transform the schema with SDK's function, then restore enum fields
transformed := anthropic.BetaJSONSchemaOutputFormat(a.outputFormatSchema)
restoreEnumFields(transformed.Schema, a.outputFormatSchema)
betaParams := anthropic.BetaMessageNewParams{
Model: a.model,
MaxTokens: a.maxTokens,
Messages: convertToBetaMessages(messages),
Temperature: param.Opt[float64]{Value: a.temperature},
System: []anthropic.BetaTextBlockParam{betaSystemPrompt},
OutputFormat: transformed,
Betas: []anthropic.AnthropicBeta{"structured-outputs-2025-11-13"},
}
...
As a separate test, I added "enum" to schemautil.go at line 75 (and removed this restoreEnumFields function) and it worked just fine.
Metadata
Metadata
Assignees
Labels
No labels