Apple Developer onepage/WWDC26
#WWDC26#FoundationModels#AgenticApps2026-06-08 · 21:44

把 Foundation Models session 設計成 可切換、可裁切、可評估的 agent workflow

這場 session 用一個 craft app 拆解新的 DynamicProfile、DynamicInstructions 與 Foundation Models framework utilities:同一個 LanguageModelSession 可以在不同任務階段切換模型、工具、指令與 transcript 策略。

// 一句話結論

Apple 給 agentic app 的不是單一「代理人」抽象,而是一組低階控制點:profile 決定模型與工具,history transform 決定上下文,tool calling mode 決定何時必須行動。

Apple Developer · WWDC26 · Video ID: nxW29TKIL0wApple Developer 官方頁
Content map

這支影片在拆 agentic app 的四個工程問題

任務邊界

一個 session,按階段換 profile

craft app 先 brainstorm、再 planning、再 reviewing。每個階段可以有不同 instructions、tools、temperature、reasoning level 與模型來源。

上下文管理

transcript 不是只能一路 append

不同模型有不同 context window 與隱私特性。historyTransform 可在 prompt 前裁切、摘要或移除 tool calls,且不永久改掉 session transcript。

編排模式

handoff 與 consultation 要分開看

baton-pass 讓下一個 profile 接手完整歷史並產生最終回答;phone-a-friend 則建立短命 child session,回傳 tool output 後由 parent 收尾。

可靠性

required tool calling 必須有出口

allowed、disallowed、required 可以控制工具呼叫行為;若要求模型只能 call tools,就要設計 exit condition,否則會變成無限工具迴圈。

Architecture flow

導入 DynamicProfile 的實作順序

1

先把 app 體驗拆成 mode

不要先想「一個 agent 解所有事」。把使用者旅程切成 brainstorming、planning、reviewing 這類 mode,讓每段有清楚目標。

2

用 DynamicInstructions 封裝可重用知識

將 domain instructions 與 tools 包成元件,例如 origami expert。需要時再條件式加入 profile,避免每個 prompt 都塞滿所有背景。

3

在 DynamicProfile 裡設定模型與 generation options

創意 brainstorm 可用 PCC 與較高 temperature;複雜 planning 可用 deep reasoning;低成本 reviewing 可回到 on-device system model。

4

用 history transform 管理跨模型上下文

切到較小或較私密性不同的模型時,先移除無關 entries、tool calls 或敏感內容;同時保留原始 transcript,避免後續階段失去上下文。

5

用 evaluation 驗證 context engineering

重寫歷史、加入工具或改 instructions 都可能影響 KV cache、latency 與 accuracy。影片明確提醒要用 Evaluations framework 量化效果。

實務啟發:agent 架構要先設計「誰看得到什麼」

baton-pass 與 phone-a-friend 最大差異不是命名,而是 transcript visibility 與 final answer ownership。前者讓接棒 profile 看完整歷史並完成回答;後者把子任務隔離在 child session,parent 只收工具輸出。

如果你的 app 有隱私分層或成本分層,這個差異會直接影響架構:哪些內容可傳給 server model、哪些只留在 on-device model、哪些工具輸出可放進長期 transcript,都要明確定義。
API / framework 重點LanguageModelSession.DynamicProfile、DynamicInstructions、Foundation Models framework utilities、historyTransform、custom modifiers、toolCallingMode、transcriptErrorHandlingPolicy。
遷移注意事項從單一 session prompt 升級到多 profile 後,要重新測 context window、model switch、tool visibility、錯誤後 transcript rollback / preserve,以及 UI 是否能解釋 agent handoff。

風險與測試清單

第一,required tool calling 要有終止條件,例如狀態變數或 final answer tool。第二,修改 transcript 會影響 KV cache,可能拉高 time-to-first-token。第三,新增工具或更動歷史可能讓模型困惑,出現「以前不用工具,現在也不用」的錯誤學習。

建議把不同 profile、不同 history transform、不同 tool calling mode 放進 eval set 比較,不要只靠 demo prompt 判斷。這類 agentic app 的品質通常壞在邊界條件,而不是 happy path。

// TL;DR