← All courses ← Course home

Lesson 02 of 05

Profiles and several sessions

Dynamic Profiles switch one active specialist inside a session. Parallel agreement needs several LanguageModelSession values.

Agent brief (llms.md)

A LanguageModelSession.DynamicProfile picks one Profile each time the model is prompted. Instructions, tools, and the model can change with app state. Only one profile is active in that session. This is not parallel voting.

App stateMode or flag
DynamicProfileOne Profile
PromptThat specialist
import FoundationModels
import Observation

@Observable
final class ReviewBoard {
    enum Seat: String { case planner, critic, judge }
    var seat: Seat = .planner
}

struct ReviewProfile: LanguageModelSession.DynamicProfile {
    var board: ReviewBoard

    var body: some LanguageModelSession.DynamicProfile {
        switch board.seat {
        case .planner:
            Profile {
                Instructions("Propose one concrete action. Do not execute it.")
            }
            .model(SystemLanguageModel.default)
        case .critic:
            Profile {
                Instructions("List only concrete risks in the proposed action.")
            }
            .model(SystemLanguageModel.default)
        case .judge:
            Profile {
                Instructions("Approve, reject, or escalate. Reply with one word first: approve, reject, or escalate.")
            }
            .model(SystemLanguageModel.default)
        }
    }
}

let board = ReviewBoard()
let session = LanguageModelSession(profile: ReviewProfile(board: board))

Apple also names two patterns in WWDC26 session 242. Baton-pass stays in one session and changes which profile is active. Phone-a-friend opens a short child session and returns its reply as tool output. Use those names as Apple uses them. Then say what they do in plain words.

Switch hatsDynamic Profile
Ask a peerChild session
Vote togetherSeveral parent sessions

Weighted voting needs several independent replies. Create several LanguageModelSession values, each with its own instructions. Do not expect one Dynamic Profile body to produce three concurrent votes. You can still use a profile later for the judge seat.

Read Pause and resume long AI jobs, Stop prompt attacks and leaks, and Talk to tools with MCP if a vote round must pause, or if a specialist prompt might carry an injection.

Rule. Dynamic Profiles switch one active seat. Parallel agreement uses more than one LanguageModelSession.

Next, collect weighted votes in app code.

Key concepts

  • A Dynamic Profile picks one active Profile each time the model is prompted.
  • Baton-pass changes which profile is active on one session.
  • Phone-a-friend is a short child session whose reply returns as tool output.
  • Weighted voting needs several independent sessions.

Takeaways

  • Dynamic Profiles switch one active seat, not parallel votes.
  • Use several parent sessions to vote together.
  • Do not expect one Profile body to produce three concurrent votes.