← All courses ← Course home

Lesson 03 of 05

Apply the route with modifiers

The router returns a key. The Dynamic Profile applies .model and .reasoningLevel on the one active Profile.

Agent brief (llms.md)

WWDC26 session 241 shows a brainstorm Profile using PCC plus .reasoningLevel(.deep), and a cheaper analysis Profile on SystemLanguageModel. Your router is the function that picks that branch. The Profile body is the switch.

Rulechoose()
ProfileOne branch
Modifier.model / .reasoningLevel
import FoundationModels
import CoreAI

// Illustrative. Confirm LanguageModel initializers in the installed SDK.
struct RoutedProfile: LanguageModelSession.DynamicProfile {
    let route: String
    let system: SystemLanguageModel
    let pcc: PrivateCloudComputeLanguageModel
    let coreAI: CoreAILanguageModel?

    var body: some LanguageModelSession.DynamicProfile {
        switch route {
        case "pcc":
            Profile {
                Instructions { "Plan the next step. Stay inside the packed facts." }
            }
            .model(pcc)
            .reasoningLevel(.deep)
        case "coreai":
            Profile {
                Instructions { "Answer in the baked voice. Do not invent facts." }
            }
            .model(coreAI!)
        default:
            Profile {
                Instructions { "Answer quickly from the packed facts." }
            }
            .model(system)
        }
    }
}

Force-unwrapping coreAI is only safe after choose proved it is available. Prefer an enum with associated models over a string key in production.

When you hop from PCC to the system model, trim the transcript with historyTransform so the smaller window still fits. Session 242 covers that handoff. Do not send private tool dumps to a larger model if the user bound the turn to the device.

One Profile. The body re-evaluates each prompt. Do not keep two sessions "just in case."

Next, wrap choose and the Profile in one router type.

Key concepts

  • A routed Dynamic Profile switches on the route key.
  • Apply .model and .reasoningLevel on the active Profile.
  • Trim transcript with historyTransform when hopping from PCC to the system model.
  • One Profile. The body re-evaluates each prompt.

Takeaways

  • The router returns a key. The Profile body is the switch.
  • Only force-unwrap a Core AI model after choose proved it is available.
  • Do not keep two sessions just in case.