# Hail: Build reactive, durable llm agents in Swift

**URL:** <https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833>\
**Category:** Community Showcase\
**Tags:** distributed, distributed-actors, agent, llm, agents\
**Created:** [August 7, 2026, 2:42pm UTC](https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833 "2026-08-07T14:42:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaleel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jaleel/32/45076_2.png) [@jaleel](https://forums.swift.org/u/jaleel)\
**Post date:** [August 7, 2026, 2:42pm UTC](https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833/1 "2026-08-07T14:42:25Z")

</div>

Hello everyone,

I would like to share with you [Hail](https://github.com/akbashev/hail), a Swift runtime for building durable, distributed LLM agents.

 ![hail_pic_light](https://global.discourse-cdn.com/swift/original/3X/b/2/b259423e3474e63794e6007ea47cefd1f04e35fa.jpeg)

> 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](https://martinodersky.substack.com/p/tracked-capabilities-for-safer-agents) on tracked capabilities for safer agents, adapted to the concurrency model of Swift.

**A small example:**

```swift
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](https://github.com/huggingface/AnyLanguageModel) for the model abstractions and [swift-acp](https://github.com/wiedymi/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](https://github.com/akbashev/hail)

---

<div class="post-metadata">

**Author:** ![jaleel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jaleel/32/45076_2.png) [@jaleel](https://forums.swift.org/u/jaleel)\
**Post date:** [August 7, 2026, 2:50pm UTC](https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833/2 "2026-08-07T14:50:18Z")

</div>

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

 ![Screenshot 2026-08-07 at 16.43.58](https://global.discourse-cdn.com/swift/original/3X/f/d/fd6f9f19098844b3f3f313c70b9f7a4e0fd95c95.jpeg)

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? 😅) 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.

---

<div class="post-metadata">

**Author:** ![Lin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lin/32/44031_2.png) [@Lin](https://forums.swift.org/u/Lin)\
**Post date:** [August 8, 2026, 12:43am UTC](https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833/3 "2026-08-08T00:43:29Z")

</div>

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](https://code.claude.com/docs/en/cross-session-messaging)

---

<div class="post-metadata">

**Author:** ![jaleel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jaleel/32/45076_2.png) [@jaleel](https://forums.swift.org/u/jaleel)\
**Post date:** [August 12, 2026, 11:49am UTC](https://forums.swift.org/t/hail-build-reactive-durable-llm-agents-in-swift/88833/4 "2026-08-12T11:49:04Z")

</div>

> [@Lin](#):
>
> Though for the common case, single host with multiple OS processes might be enough, with distribution added back as the project scales.

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

> [@Lin](#):
>
> I'd like to try your Stagehand project. Thanks for sharing.

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

> [@Lin](#):
>
> Claude code just released something similar that only handle single host, multiple process communication: [cross-session-messaging](https://code.claude.com/docs/en/cross-session-messaging)

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.
