Repository navigation
feat(ai): structured output for ai/chat & ai/agent (ADR-0030) - #95
Merged
gustavobertoi merged 1 commit intoJun 4, 2026
Merged
Conversation
…spond (ADR-0030)
Opt-in: an outputSchema input (list of {name,type,required,description}) makes the
node return a validated object instead of free-form text. A single forced
"respond" tool carries the schema (ParameterSchemaToJSONSchema) with
ToolChoice=required; the tool-call args are parsed and validated, with one
bounded repair retry. Works on every provider (all support tool calling). The
agent runs its normal loop then coerces the final answer. Absent outputSchema =
unchanged.
Provider-native response_format (Option B) deferred. ADR-0030 Proposed -> Accepted.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Third "finish the agents" leaf PR. ADR-0030 tool-forced structured output.
What
Opt-in: an
outputSchemainput (a list of{name,type,required,description}fields) makesai/chatand
ai/agentreturn a validated object instead of free-form text (backward compatible — absent= unchanged).
How
A single forced
respondtool carries the schema (ParameterSchemaToJSONSchema) withToolChoice: "required"; the tool-call arguments are parsed and validated against the schema, withone bounded repair retry, then
FunctionError. Works on every provider (all support toolcalling — verified both openaicompat and anthropic map
ToolChoice:"required"). The agent runs itsnormal reasoning loop, then coerces the final answer. Logic in
internal/packages/functions/ai/structured.go.Scope
Provider-native
response_format/json_schema(Option B optimization, with a per-providercapability map) is deferred. ADR-0030
Proposed → Accepted.Verify
make lint0 ·make buildok ·make test710 pass ·make swaggerok. Tests cover theforced-respond happy path, validation (required/type), parse fallbacks, and the ai/chat structured
path end-to-end.
This completes the three leaf agent capabilities (0028/0029/0030). The orchestrator (0026) +
async-tools (0027) pair stays Proposed for reassessment.
🤖 Generated with Claude Code