You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Foundation Models 27 dynamic profile composition APIs - #314
Adds profile composition only: DynamicProfile, Profile, erasure, conditional builders, modifiers, and request-time resolution of those values. No profile session initializer, lifecycle execution, native projection, or provider Tool-loop changes.
Dependencies: #313 and upstream #352 (which replaced/closed#311). Shared compatibility runtime is separate in #315; provider integrations remain individual PRs.
API compatibility
Composition follows the installed Foundation Models 27 SDK, including callback actor-context/isolation annotations.
historyTransform accepts an ordinary escaping closure, not @sendable, matching Apple. A non-Sendable function/capture now compiles with both modules.
CI=1 GIT_CONFIG_GLOBAL=/dev/null swift test: 848 tests in 89 suites passed.
Regression first reproduced the non-Sendable-to-@sendable compile error. After the fix, equivalent ordinary function values compile against AnyLanguageModel and FoundationModels; a runtime test executes a transform capturing a non-Sendable reference.
Strict Swift format lint on changed files and git diff --check passed.
The main-based diff includes unmerged #313; review the profile-specific files for this layer. Published history is preserved; no force-push or new checkout.
The updated #313 dependency preserves concrete Tool identity in public RequestContext and binds session properties only for execution. historyTransform remains an ordinary, non-@sendable closure; no construction API or provider runtime moved into this PR.
Two streams created back-to-back can append both prompts before their asynchronous profile resolutions run. Both snapshots then end with the second prompt, so this lookup dispatches onPrompt for that prompt and skips the first request's prompt. Pass the actual request prompt into lifecycle preparation instead of inferring it from shared history, and deduplicate prompt dispatch per request across continuations.
Profile sessions now enter SystemLanguageModel's dynamic-instructions branch, but makeFoundationModelsSession builds its history from session.transcript (SystemLanguageModel.swift:404–412), not the resolved request projection. Thus a profile's historyTransform is ignored even on the initial system-model request, resending entries the transform removed. Build native history from the resolved RequestContext.transcript, filtering its instructions and duplicate current prompt without changing durable history.
The additional prompt-dispatch and native-history findings are also addressed in 9b76d74. Lifecycle preparation receives the actual request prompt and shares a per-request dispatch state across continuations, including concurrent streams. Native Foundation Models session construction now uses the resolved request projection. Regression coverage includes history mutation removing the current prompt, concurrent prompt callbacks, and native projected history without changing durable history. The 34 focused profile/property/options tests pass.
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
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.
Scope after review
Adds profile composition only: DynamicProfile, Profile, erasure, conditional builders, modifiers, and request-time resolution of those values. No profile session initializer, lifecycle execution, native projection, or provider Tool-loop changes.
Dependencies: #313 and upstream #352 (which replaced/closed #311). Shared compatibility runtime is separate in #315; provider integrations remain individual PRs.
API compatibility
historyTransformaccepts an ordinary escaping closure, not @sendable, matching Apple. A non-Sendable function/capture now compiles with both modules.includeSchemaInPromptis Compatibility SPI.Fresh validation (2026-10-21)
303f8a1; preserved the upstream Add Foundation Models 27 request options #352 options/defaults, Let callers set how many tool rounds a response takes #331 maximumToolRounds, Honour the tool execution delegate in SystemLanguageModel #297 native delegate, and Replay OpenAI tool calls as plain, stable JSON #325 JSON replay changes.CI=1 GIT_CONFIG_GLOBAL=/dev/null swift test: 848 tests in 89 suites passed.git diff --checkpassed.The main-based diff includes unmerged #313; review the profile-specific files for this layer. Published history is preserved; no force-push or new checkout.
The updated #313 dependency preserves concrete Tool identity in public RequestContext and binds session properties only for execution.
historyTransformremains an ordinary, non-@sendable closure; no construction API or provider runtime moved into this PR.