Skip to content

feat: add WWDC26 Apple Intelligence APIs#218

Open
JKobrynski wants to merge 5 commits into
callstackincubator:mainfrom
JKobrynski:feat/apple-foundation-models-followup
Open

feat: add WWDC26 Apple Intelligence APIs#218
JKobrynski wants to merge 5 commits into
callstackincubator:mainfrom
JKobrynski:feat/apple-foundation-models-followup

Conversation

@JKobrynski

Copy link
Copy Markdown
Contributor

Related PR - #215

Summary

Builds on the WWDC26 Apple Intelligence API work from #215 and finishes the JS-facing history management API for @react-native-ai/apple.

PR #215 added the broader Apple Intelligence surface, including Apple provider options, model info APIs, iOS 27 Private Cloud Compute support, image prompts, Image Playground generation, Vision built-in tools, and lower-level native helpers. It also introduced context/history utilities internally.

This change exposes those history management utilities as fluent AI SDK model wrappers so consumers can compose Apple history behavior directly from JS:

const summarizerModel = apple()

const model = apple()
  .summarizeHistory(5000, summarizerModel)
  .rollingWindow(10)
  .droppingCompletedToolCalls()

It also adds demo app controls for testing the behavior without replacing the existing basic chat flow.

Changes

  • Add fluent Apple model wrappers for:
    • summarizeHistory(threshold, model)
    • rollingWindow(entries)
    • droppingCompletedToolCalls()
  • Apply history transforms before both doGenerate and doStream
  • Preserve dynamic tool configuration when wrapping Apple language models
  • Keep transform ordering aligned with Apple-style chained history utilities
  • Export Apple language model types needed by consumers and the demo app
  • Add Apple History Demo controls to the Expo example app
  • Add settings for enabling history management, rolling window size, and summary threshold
  • Preserve the existing basic chat demo behavior when the history demo is disabled
  • Document the fluent history management API in the package README and website docs
  • Include [codex] Add WWDC26 Apple Intelligence APIs #215’s WWDC26 Apple Intelligence API work as the base for this follow-up

Testing

  • Ran bun run --filter='@react-native-ai/apple' typecheck
  • Ran bun run --filter='@react-native-ai/example' typecheck
  • Ran bun lint
  • Ran git diff --check
  • Tested manually in the Expo demo app on iOS 26.5 with Apple Intelligence selected
  • Verified basic chat still works with the Apple History Demo disabled
  • Verified history transforms run when the Apple History Demo is enabled
  • Verified rolling window trims older conversation entries while preserving system context
  • Verified summarization applies when the prompt exceeds a low test threshold
  • Verified completed tool-call pruning with a synthetic tool-call history path
  • Removed temporary debug logging after validation

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@JKobrynski is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@JKobrynski JKobrynski marked this pull request as ready for review June 17, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Exposes Apple Foundation Models “history management” utilities (summarization, rolling window, completed tool-call pruning) as fluent JS model wrappers in @react-native-ai/apple, adds native support for model info + Image Playground, and extends the Expo example app to toggle/demo the new behaviors.

Changes:

  • Add fluent Apple language model wrappers (summarizeHistory, rollingWindow, droppingCompletedToolCalls) and apply transforms before both doGenerate and doStream.
  • Add native APIs for getModelInfo and generateImages, plus JS exports/types and updated docs/README.
  • Add “Apple History Demo” toggles + sliders in the Expo example app and preserve existing chat behavior when disabled.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
website/src/docs/apple/generating.md Updates Apple provider docs (availability, PCC, images, history helpers, error handling).
packages/apple-llm/src/NativeAppleLLM.ts Extends TurboModule typings to support attachments/providerOptions + new native methods.
packages/apple-llm/src/index.ts Exports new Apple provider types + trimAppleMessagesForContext.
packages/apple-llm/src/AppleFoundationModels.ts Adds JS fallbacks/wrappers for getModelInfo and generateImages.
packages/apple-llm/src/ai-sdk.ts Implements fluent history wrappers, image model, prompt attachment handling, and model-info API.
packages/apple-llm/README.md Documents new features and requirements + shows fluent history usage.
packages/apple-llm/ios/AppleLLMImpl.swift Implements getModelInfo, Image Playground generation, attachments, PCC, Vision tools plumbing.
packages/apple-llm/ios/AppleLLMError.swift Refines invalid-message error shape/message.
packages/apple-llm/ios/AppleLLM.mm Bridges new options + adds getModelInfo/generateImages TurboModule methods.
apps/expo-example/src/store/chatStore.ts Adds persisted settings for the Apple History Demo.
apps/expo-example/src/screens/ChatScreen/SettingsSheet.tsx Adds History Demo toggle + sliders for window/threshold.
apps/expo-example/src/screens/ChatScreen/index.tsx Applies fluent history wrappers when demo enabled; improves empty state text plumbing.
apps/expo-example/src/screens/ChatScreen/ChatMessages.tsx Accepts precomputed empty-state subtitle from parent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +456 to +468
function isToolRelatedMessage(message: LanguageModelV3Message) {
if (message.role === 'tool') {
return true
}

if (message.role !== 'assistant') {
return false
}

return message.content.some(
(part) => part.type === 'tool-call' || part.type === 'tool-result'
)
}
Comment on lines +93 to +102
export interface AppleContextOptions {
/**
* Keep the first system message and only the last N non-system messages.
*/
rollingWindowMessages?: number
/**
* Remove completed tool-call/tool-result entries from older context.
*/
dropCompletedToolCalls?: boolean
}
Comment on lines +190 to +195
if (file.type === 'url') {
return {
mediaType: 'image/png',
data: file.url,
}
}
Comment thread packages/apple-llm/ios/AppleLLMImpl.swift Outdated
Comment on lines +760 to +762
throw new Error(
`Unsupported Apple Foundation Models message content type: ${JSON.stringify(part)}`
)
@artus9033 artus9033 changed the title feat: Add WWDC26 Apple Intelligence APIs feat: add WWDC26 Apple Intelligence APIs Jun 17, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@grabbou

grabbou commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Please have a look at outstanding copilot comments and decide whether to address them or not.

Quick comment:

Add fluent Apple model wrappers for:
summarizeHistory(threshold, model)
rollingWindow(entries)
droppingCompletedToolCalls()

Would that be AI SDK native way, or shall we instead use options via apple() object? For example: apple({ rollingWindow: XX })

I am more familiar with the latter.

@grabbou

grabbou commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Please do a follow-up after this one is merged to #217 - I guess partial support for private cloud compute is done here, but we also need to do support for "reasoning" option, some errors and potentially other things (exact diff to be checked).

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