SwiftAutoGUI 1.0 runs its Mac agent on Apple's models or OpenAI

2 hours ago

SwiftAutoGUI is a Swift library that drives a Mac: the mouse, the keyboard, screenshots, and an agent that works toward a goal. Version 1.0 rebuilds that agent on Apple's Foundation Models, so it can run on the Mac, on Private Cloud Compute, or on OpenAI. It requires macOS 27.

Ask about this presentation

Chapters

  1. 0:00SwiftAutoGUI 1.0
  2. 0:20Agent(model:)
  3. 0:42sagui agent --provider
  4. 1:03Invalid actions throw
  5. 1:26One conversation per run
  6. 1:48Requires macOS 27
  7. 2:11Backend to model
  8. 2:29Removed and renamed
  9. 2:55When to upgrade
Show transcript
  1. SwiftAutoGUI is a Swift library that drives a Mac: the mouse, the keyboard, screenshots, and an agent that works toward a goal. Version 1.0 rebuilds that agent on Apple's Foundation Models, so it can run on the Mac, on Private Cloud Compute, or on OpenAI. It requires macOS 27.

    Slide text

    SwiftAutoGUI 1.0 runs its Mac agent on Apple's models or OpenAI

    On-device, Private Cloud Compute or OpenAI

    Requires macOS 27

  2. The agent no longer takes a backend. It takes any Foundation Models language model. Apple's on-device model needs no API key. Private Cloud Compute runs on Apple's servers. For OpenAI, a new factory wraps Apple's Chat Completions adapter, in place of the Responses API. Action generation takes the same models.

    Slide text

    The agent takes a model now, not a backend

    SystemLanguageModel.default

    Runs on this Mac. No API key.

    PrivateCloudComputeLanguageModel()

    Runs on Apple's servers. Needs Apple's entitlement.

    AutomationModels.openAI(apiKey:)

    OpenAI over Chat Completions. Takes a base URL.

    Agent(model:)
    ActionGenerator(model:)

    Any Foundation Models LanguageModel

  3. On the command line, the default changed. A plain agent command now runs on the on-device model, with no API key. For OpenAI, add the provider flag; the key still comes from your environment. Private Cloud Compute needs an entitled app, and falling back to on-device is a flag you choose. A cloud fallback is never automatic.

    Slide text

    The sagui agent starts on the on-device model

    # Default: on-device, no API key required sagui agent "Press Save" --vision-mode automatic
    # Explicit remote provider, OPENAI_API_KEY from the environment sagui agent "Open Safari" --provider openai --model gpt-5.6-sol
    # Only in an eligible, entitled host sagui agent "Inspect the screen" --provider pcc --fallback-on-device
  4. Before this release, a bad action from the model could quietly become a zero second wait: a broken URL, an invalid app name, a shortcut with no valid keys. Now it throws before anything happens. Shortcut keys use the library's own Key enum, so every model picks from real key names. And a failure or a change on screen stops the rest of a batch.

    Slide text

    A bad generated action now throws instead of becoming a pause

    0.30

    guard let url = validatedHTTPURL(url) else { return .wait(0) }

    1.0

    throw ActionGeneratorError.invalidResponse(detail: …)
    .keyShortcut(keys: ["command", "space"])
    .keyShortcut(keys: [.command, .space])
  5. Each run now owns one session, and the session holds the conversation. By default it keeps four completed turns and up to twelve thousand characters, and drops old screenshots. If the model still runs out of context, the agent retries once with fresh history. A fallback model starts fresh too, with the goal, the current screen and the latest results.

    Slide text

    Each run keeps one conversation, trimmed to fit

    4
    completed turns kept by default
    12,000
    characters of history, old screenshots dropped
    1
    retry with fresh history after a context-size error

    A fallback model starts fresh with the goal, the current screen and the latest results.

  6. Now the breaking part. Version 1.0 requires macOS 27. You also need the Xcode 27 SDK and Swift tools 6.2, and Apple Intelligence turned on for Apple's models. On macOS 26, stay on the 0.30 line. The package also pins Apple's Foundation Models utilities to an exact beta.

    Slide text
    macOS 27

    Xcode 27 SDK · Swift tools 6.2 · Apple Intelligence on for Apple's models

    The 0.30 release line supports macOS 26.

    Pinned dependency

    apple/foundation-models-utilities exact: "1.0.0-beta5"

  7. Most of your code change is one swap. Before, you built a backend, like the OpenAI vision backend, and handed it to the agent or the action generator. Now you hand over a model: the OpenAI factory on AutomationModels, or Apple's system language model for on-device work.

    Slide text

    Swap the backend for a model

    Before

    let backend = OpenAIVisionBackend(apiKey: key) let agent = Agent(backend: backend) let generator = ActionGenerator(backend: FoundationModelsBackend())

    After

    let agent = Agent(model: AutomationModels.openAI(apiKey: key)) let generator = ActionGenerator(model: SystemLanguageModel.default) let actions = try await generator.generateActionSequence(from: "Type hello")
  8. A few more edits. Both generator protocols are gone, so a custom provider implements Apple's LanguageModel and LanguageModelExecutor. AgentResponse becomes AgentDecision. Converting a generated action now throws, so add try. And the reasoning effort option is gone, because Apple's adapter doesn't forward it. Scripts that counted on OpenAI as the default need the provider flag.

    Slide text

    Custom providers, decisions and toAction() change too

    VisionActionGenerating → LanguageModel + LanguageModelExecutor
    AgentResponse → AgentDecision
    action.toAction() → try action.toAction()
    sagui agent "…" --reasoning-effort low → sagui agent "…" --provider openai
  9. So upgrade once your Macs run macOS 27, with Apple Intelligence on if you use Apple's models. Private Cloud Compute also needs Apple's managed entitlement in your app. The core change is the swap you saw: a backend becomes a model, on the Mac, on Apple's servers, or on OpenAI. The migration guide is on the documentation site, next to the newly published browser agent guide.

    Slide text

    Upgrade once your Macs run macOS 27

    Private Cloud Compute also needs Apple's managed entitlement in your app.

    Migration guide and browser agent guide

    nakaokarei.github.io/
    SwiftAutoGUI/documentation

    Migrating to macOS 27 language models, on the SwiftAutoGUI documentation site

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built in New York with ❤️