Conversation
Foundation Models declares GenerationOptions and its SamplingMode as Sendable and Equatable only. AnyLanguageModel also made both Codable, and decoding GenerationOptions dropped any custom options set for a model, so a round trip didn't preserve the value. Remove Codable from GenerationOptions and SamplingMode, along with the code that encoded custom options by type name. Transcript.Prompt is still Codable, so it now codes its options itself: the sampling mode, temperature, and maximum response tokens use the same format as before, and custom options are no longer written. Prompts encoded by earlier releases still decode.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation preserves the documented transcript format and is adequately tested.
Review effort: Balanced
Findings: None
What changed in this PR
Removes misleading Codable conformances while preserving transcript serialization compatibility.
Changes:
- Removes direct coding support for generation and custom options.
- Adds transcript-specific option coding that omits custom options.
- Adds compatibility and round-trip tests.
| File | Description |
|---|---|
GenerationOptions.swift |
Removes conformances and adds transcript coding representation. |
Transcript.swift |
Implements explicit prompt coding. |
TranscriptTests.swift |
Tests encoding and backward-compatible decoding. |
CustomGenerationOptionsTests.swift |
Removes obsolete direct-coding tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Foundation Models declares
GenerationOptionsandGenerationOptions.SamplingModeasSendableandEquatableonly. AnyLanguageModel also makes bothCodable, and decodingGenerationOptionsdrops any custom options set withoptions[custom:], so an encode and decode round trip doesn't give back the same value.This PR removes
CodablefromGenerationOptionsandSamplingMode, along with the code that encoded custom options by type name.Transcript.PromptstaysCodableand now codes its options itself. The sampling mode, temperature, and maximum response tokens use the same format as before, custom options are no longer written, and prompts encoded by earlier releases still decode.This is source-breaking for code that encodes or decodes
GenerationOptionsorSamplingModedirectly, or that uses them in its own synthesizedCodabletypes. Encoded transcripts no longer include custom options such asextraBody, and an earlier release can't decode a prompt encoded by this one, because it expects acustomOptionsStoragekey.