Commit Graph
9 Commits
Author SHA1 Message Date
Kyle MisteleandGitHub e5a14e6110 Merge branch 'dev' into dev 2026-01-19 15:06:07 -08:00
Kyle MisteleandClaude Opus 4.5 b1da5714d7 test: add retry behavior tests for structured output
Add 5 new unit tests that verify the retry mechanism for structured
output validation:
- Multiple validation failures trigger multiple onError calls
- Success after failures correctly calls onSuccess
- Error messages guide model to fix issues and retry
- Simulates retry state tracking matching prompt.ts logic
- Simulates successful retry after initial failures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 11:28:29 -08:00
Kyle MisteleandClaude Opus 4.5 4c7c65a054 merge: resolve conflicts from upstream dev
Merge upstream changes while preserving structured output feature:
- Keep tools deprecation notice from upstream
- Keep bypassAgentCheck parameter from upstream
- Keep variant field on user messages from upstream
- Preserve outputFormat and StructuredOutput tool injection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:01:34 -08:00
Kyle Mistele d2beb78457 feat: structured output 2026-01-12 23:54:53 -08:00
Kyle Mistele 0e8f7694ed fix: force tool calls when outputFormat is json_schema
When structured output is requested, the model must call the
StructuredOutput tool instead of responding with plain text.

Changes:
- Add toolChoice parameter to LLM.StreamInput
- Pass toolChoice: "required" to streamText when outputFormat is json_schema
- This forces the model to call a tool, ensuring structured output is captured
2026-01-12 23:05:43 -08:00
Kyle Mistele 34f9feb12d docs: add structured output documentation to SDK reference
Document the outputFormat feature for requesting structured JSON output:
- Basic usage example with JSON schema
- Output format types (text, json_schema)
- Schema configuration options (type, schema, retryCount)
- Error handling for StructuredOutputError
- Best practices for using structured output
2026-01-12 21:04:13 -08:00
Kyle Mistele 4cb9f8ab34 fix: structured output loop exit and add system prompt
- Fix loop exit condition to check processor.message.finish instead of
  result === "stop" (processor.process() returns "continue" on normal exit)
- Add system prompt instruction when json_schema mode is enabled to ensure
  model calls the StructuredOutput tool
- Add integration tests for structured output functionality
- Fix test Session.messages call to use object parameter format
2026-01-12 20:51:17 -08:00
Kyle Mistele d582dc1c9f chore: regenerate JavaScript SDK with structured output types
Regenerate SDK types to include outputFormat and structured_output fields.
2026-01-12 20:18:50 -08:00
Kyle Mistele 32ef11da1f feat: add structured output (JSON schema) support
Add outputFormat option to session.prompt() for requesting structured JSON
output. When type is 'json_schema', injects a StructuredOutput tool that
validates model output against the provided schema.

- Add OutputFormat schema types (text, json_schema) to message-v2.ts
- Add structured_output field to AssistantMessage
- Add StructuredOutputError for validation failures
- Implement createStructuredOutputTool helper in prompt.ts
- Integrate structured output into agent loop with retry support
- Regenerate OpenAPI spec with new types
- Add unit tests for schema validation
2026-01-12 20:09:51 -08:00