Skip to content

Integrate dynamic profiles with OpenAI Tool loops - #344

Merged
mattt merged 62 commits into
huggingface:mainfrom
qoli:codex/upstream-profile-openai
Nov 5, 2026
Merged

mattt merged 62 commits into
huggingface:mainfrom
qoli:codex/upstream-profile-openai

Conversation

@qoli

@qoli qoli commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Scope

OpenAI Chat Completions / Responses integration for #315's shared Compatibility SPI. Provider PRs are siblings, not a chain.

Depends on #315 cf4ad0d, transitively #314/#313 and main's #352. Isolated layer comparison.

  • Resolve a profile before each actual request and bind callbacks/Tools to that producing request.
  • Preserve canonical/pending history, earlier text, shared nondefault round budgets and the full handoff error payload.
  • Retain ordinary provider history behavior; preserve repeated calls and round-scoped outputs rather than globally deduplicating call IDs.
  • Retain complete committed-entry identity for hooks/Tools and the public raw-Tool boundary.

Both APIs retain upstream #325 stable/plain JSON replay and assistant-content metadata. Each complete ToolCalls entry is created before hooks/Tool execution and committed unchanged.

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 continuation mapper carries the producing API host into reasoning replay. A Tool round's reasoning is retained once before its stable ToolCalls entry and dispatched to that producing request's profile before Tool callbacks can switch profiles. Ordinary/profile and streaming/non-streaming request-history regressions first failed, then passed; a separate before/after-profile-switch regression reproduced both callback failures before the dispatch fix. Upstream host filtering, stable/plain JSON arguments, final-request usage, injected transport and timeout semantics are preserved.

Fresh local verification (2026-10-23)

Head 5e95c10. CI=1 GIT_CONFIG_GLOBAL=/dev/null swift test: 957 tests / 100 suites passed. The separate upstream macro test target also passed 2 tests / 1 suite. Strict formatting/diff checks passed. These are compile/offline tests, not live API, model-weight or Apple Intelligence inference acceptance.

The offline suites retain streaming/non-streaming history, callback, reused-ID and handoff accounting regressions. Constructor visibility is still SPI; no new PR or force-push.

qoli added 30 commits October 9, 2026 16:06
…dynamic-profiles

# Conflicts:
#	Sources/AnyLanguageModel/LanguageModelSession.swift
#	Sources/AnyLanguageModel/SessionProperties.swift
#	Sources/AnyLanguageModelMacros/SessionPropertyEntryMacro.swift
#	Tests/AnyLanguageModelTests/APICompatibilityAnyLanguageModelTests.swift
#	Tests/AnyLanguageModelTests/APICompatibilityFoundationModelsTests.swift
#	Tests/AnyLanguageModelTests/SessionPropertyTests.swift
…dynamic-profiles

# Conflicts:
#	Sources/AnyLanguageModel/SessionProperties.swift
#	Tests/AnyLanguageModelTests/SessionPropertyTests.swift
…dynamic-profiles

# Conflicts:
#	Sources/AnyLanguageModel/LanguageModelSession.swift
…ofile-tool-continuations

# Conflicts:
#	Sources/AnyLanguageModel/DynamicProfile.swift
#	Sources/AnyLanguageModel/LanguageModelSession.swift
qoli and others added 18 commits October 21, 2026 09:13
Take main for everything that PR 315 and PR 377 own and keep only the
OpenAI tool loop integration from this branch. Send PR 377's schema text
through the profile's tool continuation messages.

Keep the new resolution's callback history and history version when a
request context shares callback state with the prepared request. Without
them, each callback history write after the first tool round reported a
conflict. Count the profile's instructions entry, which main records, in
the handoff fixtures.
@mattt
mattt requested a balanced review from Copilot November 5, 2026 19:47

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@mattt
mattt merged commit d5773fe into huggingface:main Nov 5, 2026
12 checks passed
mattt added a commit to qoli/AnyLanguageModel that referenced this pull request Nov 5, 2026
main has the shared profile runtime from huggingface#315 and the work in huggingface#344 to huggingface#348,
so main's version is kept for all files except SystemLanguageModel.swift
and NativeProfileHistoryTests.swift.

The tests now expect what main does when it creates a profile session:
it evaluates the profile once and records an instructions entry.
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.

3 participants