Hail: Build reactive, durable llm agents in Swift

Hello everyone,

I would like to share with you Hail, a Swift runtime for building durable, distributed LLM agents.

Please note this is an early-stage implementation—many details can still change. I have also used coding agents to help me as a solo developer to deliver the work, while I keep track of the implementation and the design myself.

Hail an agent—it answers from wherever it lives. The name comes from hailing a ship—or a spacecraft—and inviting it to reply. And this is not only a metaphor: an agent keeps the same stable address whether it runs on your local node, on a machine across the network, or on any node across the globe —or, one day, a spacecraft. It can be idle, recovered after a failure, or moved to another machine; you just hail it, and it answers.

The core idea: LLMs are tools, not the foundation of your product. I believe agent infrastructure should belong to everyone, not only to big tech. Hail is built on open-source Swift and keeps every model provider replaceable—hosted API, local, self-hosted, or your own integration behind one ModelEndpoint protocol. No provider is privileged by the architecture: your agent definitions, tools, authority policies, and event journal stay the same when you change vendors. Small teams and individual developers should be able to build agent products without asking permission from a platform.

The second point where I take a clear position: most agent frameworks today are built around a loop—while true, the host keeps the agent alive, polls, retries, and owns the control flow. And because a loop dies with the process, they then build durable workflows on top of it: external orchestrators, checkpoint stores, retry plumbing—durability at the wrong granularity, owned by the framework instead of the agent. I think this is the wrong abstraction. Hail follows the virtual actor model with event sourcing instead: an isolated agent owns its state, receives a message, reacts, emits durable events, and then becomes idle. There is no loop to keep alive, no process to babysit, and no orchestrator to reconcile with reality. A message arrives, the agent activates—possibly on another node, possibly after weeks of being idle—replays its journal if needed, reacts, and sleeps again. Durability belongs to the entity, not to the framework around it. The runtime manages the lifecycle; you just address the agent.

How it works:

  • Distributed actors—an agent is an isolated, stateful actor with a typed message boundary. It does not belong to one process or one machine.
  • Durable entities—Virtual Actors give the agents a stable identity which survives failure: event sourcing journals every meaningful transition, and a recovered actor replays the journal. The journal is the source of truth; a warm session from a provider is only an optimization.
  • Scoped effects—an LLM can propose an action, but the host decides what this action may touch. File, process, and network operations are represented as typed values (ScopedEffect), an Authority grants or denies them, and withEffect creates a non-escapable EffectToken only inside the granted scope. Secrets travel as references (SecretRef), never as raw strings in prompts or in the logs. This is inspired by the work of Martin Odersky and collaborators on tracked capabilities for safer agents, adapted to the concurrency model of Swift.

A small example:

let scoutID = AgentID(role: Role("scout"), contextID: AgentContextID("mission-7"))

let scout: Agent = try await system.virtualActors.getActor(
    identifiedBy: VirtualActorID(rawValue: scoutID.rawValue),
    dependency: AgentSpawnConfig(agentID: scoutID, projectRootPath: projectRoot)
)

let reply: ChatResponse = try await scout.respond(
    "Survey the area and report anything unusual."
)

Requirements: Swift 6.4, and macOS 26 for the local CLI model harnesses. The current implementation builds on AnyLanguageModel for the model abstractions and swift-acp for the Agent Client Protocol integrations.


I would especially appreciate feedback on two areas:

  1. Does the ScopedEffect / Authority design provide a useful security boundary in practice?
  2. Is the combination of virtual actors and event sourcing a convincing execution model for durable agents?

The repository is here: github.com/akbashev/hail

5 Likes

One of the examples of what you can build on top of such runtime is what I'm currently doing with my project Stagehand:

Stagehand is an agent orchestration environment for software development. It gives agents tickets, project context, tools, isolated workspaces, durable conversations, and a human-controlled workflow. It can be initialised inside any existing software project. One cool (or not? :sweat_smile:) feature is that git itself is the persistence layer: Stagehand stores event-sourced journals in Git refs instead of requiring a separate database.

Each project has one supervisor. The supervisor coordinates ticket-scoped worker and reviewer agents. Workers operate in isolated Git worktrees, reviewers inspect their changes, and the supervisor manages tickets, tools, and human decisions.

I haven’t published Stagehand yet. Still changing considerably while I fine-tune it. If someone is interested in this project—just ping me or reply here.

1 Like

Very cool project. Coming from Erlang/OTP, the distributed isolation looks great for long-term reliability and security — every other agent harness I've seen is a single OS process. Though for the common case, single host with multiple OS processes might be enough, with distribution added back as the project scales.

I'd like to try your Stagehand project. Thanks for sharing.

Updates:

Claude code just released something similar that only handle single host, multiple process communication: cross-session-messaging

1 Like

Durability is quite important for this case, and distributed actors on same node work as local, so worth it to be distributed by default.

Thx for interest, will share a bit later, summer is a full of vacation time. :upside_down_face:

Seen this also, but this is about messaging inside one session afaik? Anyway think it’s a bit different purpose, for Hail it’s runtime that you can use to build products on top with any agents.

1 Like