Build a schema from Go
Withmodel and ctx configured:
NewOutputSchema returns a schema map. NewOutputFormatJSONSchema(value, strict) wraps it with the format type, name, and strict setting. You can supply a hand-written TextFormat.Format map for a provider-compatible schema.
The schema helper removes schema metadata and inlines definitions. Providers support different JSON Schema subsets; test nested objects, nullable/optional fields, enums, and strictness with your selected model.
Agent output
SetAgentConfig.Output to hastekit.NewOutputSchema(Classification{}) to configure the agent’s final output schema. This convenience path uses non-strict structured output. If you need explicit strictness, configure AgentConfig.Parameters.Text directly and leave Output unset, because Output sets that text format.
Parse only complete output
Extract assistant text from a completed response or use an agent result’sText(), then decode JSON into your application type. Check errors and interruption status before parsing. Partial streaming JSON is not a completed structured result; accumulate and parse after successful completion.
Handle refusals, output-limit exhaustion, invalid JSON, and valid JSON with unacceptable field values as separate application outcomes.