Skip to content

Document dynamic profiles - #317

Draft
qoli wants to merge 186 commits into
huggingface:mainfrom
qoli:codex/upstream-dynamic-profile-docs
Draft

qoli wants to merge 186 commits into
huggingface:mainfrom
qoli:codex/upstream-dynamic-profile-docs

Conversation

@qoli

@qoli qoli commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Draft: defer the public construction example

This remains draft. The original profile-construction/provider-hook README example must not be published as an agreed stable 1.x contract while the #315 constructor/hooks remain Compatibility SPI and the construction decision is outstanding.

No independent documentation was added. Against the current #312 README the original profile delta is still 64 added lines. The branch inherits #312's authorized Gemini 3+ / remote-URL note and upstream transport documentation through normal dependency merges.

Implementation dependencies / source ownership

Head b946bec has all ten implementation heads as ancestors. Provider source matches each owning PR; the native source adds only #312's two snapshot-preserving lowering changes over #349, retaining upstream #297's delegate. No independent provider implementation lives only here. No force-push/new checkout or profile-documentation expansion.

Upstream 1.1 synchronization

Normal history-preserving merges synchronize upstream main 7d43219, including #357 per-request usage accounting, #341 Ollama reasoning, #358 host-scoped Chat Completions reasoning, #300 response-start timeouts, #362 cancellation collection, #364 partial structured snapshots and #366/#367 bounds/reasoning/system-Tool fixes. Earlier #336 final-request usage, #340 HTTPTransport, #297/#325/#331/#343/#352/#354/#356 remain intact. No force-push, new checkout, replacement PR or extra fallback.

The integrated source retains per-request/failure usage accounting, final-request response values, host/provider-scoped reasoning replay, producing-profile callbacks, response start timeouts and partial/cancelled stream behavior. Provider files exactly match their owning PRs; the native bridge adds only #312's two snapshot lowerings over #349. The shared runtime/fixtures exactly match #315. No profile documentation or constructor visibility is expanded.

Fresh integrated verification (2026-10-23)

Same fixed checkout/source with CI=1 GIT_CONFIG_GLOBAL=/dev/null swift test:

  • Default: 1009 tests / 101 suites passed.
  • Dedicated AsyncHTTPClient scratch path: 851 / 91 passed. Existing trait guards intentionally exclude URLProtocol-only suites.
  • Separate MLX,Llama,CoreML scratch path: 1175 / 111 passed.
  • The separate upstream macro test target passed 2 tests / 1 suite in each configuration.
  • Strict formatting/diff checks passed; resolution-only Package.resolved changes were not committed.

These are compile/offline tests, not live APIs, model weights or Apple Intelligence inference. Latest-source watchOS/Linux validation must come from this head's checks, not the previous head's successful CI. Constructor visibility/default model and the separate ordinary Ollama continuation PR remain outstanding; this PR stays draft.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Streaming context propagation, callback error policy, and protected continuation history have unresolved correctness issues.

3 open findings
What changed in this PR

Implements and documents Foundation Models 27-compatible dynamic profiles, session properties, request options, and provider Tool continuations.

Changes:

  • Adds dynamic profile composition, lifecycle callbacks, session properties, and request options.
  • Supports profile reevaluation and model handoff across remote providers.
  • Adds compatibility, lifecycle, continuation, and serialization tests plus README guidance.
File Description
Tests/​AnyLanguageModelTests/​SessionPropertyTests.swift Tests session properties and history behavior.
Tests/​AnyLanguageModelTests/​RequestOptionsTests.swift Tests request-option compatibility.
Tests/​AnyLanguageModelTests/​ProviderUsageTests.swift Tests provider profile continuations.
Tests/​AnyLanguageModelTests/​FoundationModelsGenerationOptionsTests.swift Tests Foundation Models option bridging.
Tests/​AnyLanguageModelTests/​DynamicProfileTests.swift Tests profiles and lifecycle behavior.
Tests/​AnyLanguageModelTests/​APICompatibilityFoundationModelsTests.swift Checks Foundation Models API compatibility.
Tests/​AnyLanguageModelTests/​APICompatibilityAnyLanguageModelTests.swift Checks AnyLanguageModel compatibility.
Tests/​AnyLanguageModelTests/​AnthropicReasoningTests.swift Covers non-streaming Anthropic continuation.
Sources/​AnyLanguageModelMacros/​SessionPropertyEntryMacro.swift Generates session-property storage accessors.
Sources/​AnyLanguageModelMacros/​Plugin.swift Registers the new macro.
Sources/​AnyLanguageModel/​SessionProperties.swift Implements session-scoped properties and history.
Sources/​AnyLanguageModel/​ProfileToolExecution.swift Centralizes profile-aware Tool execution and handoff.
Sources/​AnyLanguageModel/​Models/​SystemLanguageModel.swift Bridges Tool-calling mode.
Sources/​AnyLanguageModel/​Models/​OpenResponsesLanguageModel.swift Adds profile-aware continuations.
Sources/​AnyLanguageModel/​Models/​OpenAILanguageModel.swift Adds profile-aware continuations.
Sources/​AnyLanguageModel/​Models/​OllamaLanguageModel.swift Adds multi-round profile continuations.
Sources/​AnyLanguageModel/​Models/​GeminiLanguageModel.swift Adds profile-aware continuations.
Sources/​AnyLanguageModel/​Models/​AnthropicLanguageModel.swift Adds non-streaming Tool continuations.
Sources/​AnyLanguageModel/​LanguageModelSession.swift Integrates profile resolution and callbacks.
Sources/​AnyLanguageModel/​GenerationOptions.swift Adds OS 27-compatible options.
Sources/​AnyLanguageModel/​DynamicProfile.swift Defines dynamic profile composition.
Sources/​AnyLanguageModel/​DynamicInstructions.swift Exposes instruction resolution internally.
Sources/​AnyLanguageModel/​ContextOptions.swift Defines request-context options.
README.md Documents request options and profiles.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/AnyLanguageModel/SessionProperties.swift Outdated
Comment thread Sources/AnyLanguageModel/LanguageModelSession.swift
Comment thread Sources/AnyLanguageModel/LanguageModelSession.swift Outdated
qoli added 30 commits October 22, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants