Repository navigation
Fix optional records and tuples in OpenAI and Anthropic structured output codecs - #10502
Merged
tim-smart merged 1 commit intoNov 9, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: aa1c981 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
…tput codecs An optional property becomes a required nullable property through optionalToNullable. Its decoded side reused the property's encoded AST, so a provider conversion ran twice: a record's pair array, or a tuple's numeric-key object, decoded once and then failed the second link with "Expected array" or "Expected object". The decoded side is now the property's type side. Co-Authored-By: Claude Opus 5.5 <[email protected]>
gabedemesa
force-pushed
the
fix-structured-output-optional-record
branch
from
November 9, 2026 20:50
47efcc3 to
aa1c981
Compare
This branch is waiting to be deployed
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.
An optional property whose type is converted for the provider can't be decoded by the OpenAI or Anthropic structured-output codecs. This covers records, which become
[key, value]pairs, and tuples, which become objects with numeric keys. The codec advertises the converted shape and then rejects that same shape.Reproduce
The same call succeeds when
valueis required. On 4.1.2 these also fail, with bothtoCodecOpenAIandtoCodecAnthropic:optionalKey(Record)optional(NullOr(Record))optional(Tuple)With
@effect/ai-openai, a tool with any of these parameters fails the model's first call.Fix
optionalToNullablereused the property's encoded form on the decoded side, so the conversion ran twice. It now usesSchemaAST.toType(type)for the decoded side. Types without a conversion are unaffected. New tests cover encoding and decoding an optional record and an optional tuple, includingnulland an absent key.Validation
pnpm test --run packages/effect/test/ai/OpenAiStructuredOutput.test.ts packages/effect/test/ai/AnthropicStructuredOutput.test.ts: 111 passed. Both new tests fail without the fix.pnpm lintandpnpm checkpass.🤖 Generated with Claude Code
Closes EFF-3562