Repository navigation
Conversation
This was referenced Oct 11, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Request-scoped profile state can leak across overlapping requests, and history handling can violate its instruction-free contract.
5 open findings
Bind callbacks to the producing request's canonical history · New Use request snapshot history for tool execution · New Serialize profile activation across awaited transitions · New Keep transcript policy request-scoped instead of session-global · New Filter instructions from durable HistoryView transcripts · New
What changed in this PR
Adds Foundation Models 27-compatible dynamic profiles, session properties, request options, and per-request lifecycle handling.
Changes:
- Adds dynamic profile composition, modifiers, callbacks, and request projections.
- Adds observable session properties and instruction-free history access.
- Adds Foundation Models 27 request-option bridging and compatibility tests.
| File | Description |
|---|---|
Sources/AnyLanguageModel/ContextOptions.swift |
Defines request-context options. |
Sources/AnyLanguageModel/DynamicInstructions.swift |
Exposes instruction resolution internally. |
Sources/AnyLanguageModel/DynamicProfile.swift |
Implements profiles, modifiers, and lifecycle handling. |
Sources/AnyLanguageModel/GenerationOptions.swift |
Adds sampling aliases and tool-calling policy. |
Sources/AnyLanguageModel/LanguageModelSession.swift |
Integrates profile resolution and callbacks. |
Sources/AnyLanguageModel/Models/SystemLanguageModel.swift |
Bridges tool-calling mode to Foundation Models. |
Sources/AnyLanguageModel/SessionProperties.swift |
Implements session-scoped property storage. |
Sources/AnyLanguageModelMacros/Plugin.swift |
Registers the session-property macro. |
Sources/AnyLanguageModelMacros/SessionPropertyEntryMacro.swift |
Generates session-property accessors and keys. |
Tests/AnyLanguageModelTests/APICompatibilityAnyLanguageModelTests.swift |
Checks AnyLanguageModel syntax compatibility. |
Tests/AnyLanguageModelTests/APICompatibilityFoundationModelsTests.swift |
Checks native Foundation Models compatibility. |
Tests/AnyLanguageModelTests/DynamicProfileTests.swift |
Exercises profiles and lifecycle behavior. |
Tests/AnyLanguageModelTests/FoundationModelsGenerationOptionsTests.swift |
Tests native option bridging. |
Tests/AnyLanguageModelTests/RequestOptionsTests.swift |
Tests new request-option values. |
Tests/AnyLanguageModelTests/SessionPropertyTests.swift |
Tests property storage and history behavior. |
README.md |
Documents Foundation Models 27 request options. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+431
to
+432
| if requestContext.callbackState.wasDispatched(entry.id) { | ||
| continue |
Comment on lines
+204
to
+207
| public func historyTransform( | ||
| _ transform: @escaping ([Transcript.Entry]) -> [Transcript.Entry] | ||
| ) -> some LanguageModelSession.DynamicProfile { | ||
| BuiltinModifiedDynamicProfile(content: self, modifier: .historyTransform(transform)) |
| } | ||
|
|
||
| /// The canonical session history after dynamic instructions. | ||
| public var history: Transcript.HistoryView { |
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.


Summary
LanguageModelSession.DynamicProfilecomposition surface and built-in modifiersStack
This PR depends on #311 and #313. After those merge, its functional change is commit
a03fd6b. Provider-owned Tool continuation support is intentionally submitted as a separate follow-up PR.Validation
swift format lint --strict --recursive .CI=1 swift test— 697 tests in 74 suites