Introducing a new way to review your PRs.

Read the announcement

hashgraph-online / hol-guard

Open-source antivirus and firewall for AI agents: block risky tools, secret access, prompt injection, malicious packages, MCP servers, plugins, and skills at runtime.

View on GitHub

44 documents · Updated Nov 23, 2026

docs / agent-swarm-orchestration

Agent swarm orchestration

Swarm is a local workspace for finding, starting, and supervising AI agents that work on projects on one computer. It joins process discovery with service-owned runs so an operator can see related work, guide managed agents, review recent activity, and connect project context without claiming control over agents started elsewhere.

Swarm operating model

Swarm separates agents into two groups. Managed agents are runs started and owned by the Swarm service. Observed agents are recognized CLI processes that Swarm can display but cannot direct. This distinction keeps visibility broad while limiting control to work that the service can identify and supervise safely.

Project grouping is based on the reported workspace. It helps an operator compare work in the same project, but it does not imply an agent hierarchy or coordinate file edits. When several agents may change the same files, the operator must choose a suitable existing worktree or project boundary.

The service supports managed launch for Codex and Claude Code when their CLIs are available. Other recognized harnesses can appear as observed agents and link back to their native application for control.

Agent discovery and ownership

Process discovery

Process discovery gives the dashboard a bounded view of recognized agent CLIs running under the current operating-system account. It uses process identity and start time to form stable observations, removes known launcher duplicates, and reports when the view is limited or unavailable. Discovery reads enough process metadata to identify the application and workspace; it does not read private transcripts or create control authority.

Observed agents show their harness, workspace, status, and limited activity facts. They have no Swarm message, interrupt, or stop controls. An operator continues work in the agent's own application.

References: rust/…/discovery.rs• L1-17 rust/…/discovery.rs• L101-153 rust/…/discovery.rs• L155-210 rust/…/model.rs• L24-28

Managed ownership

Managed ownership begins when Swarm accepts a task for a supported harness and project directory. The service assigns the run an identity and keeps its lifecycle, workspace, task, controls, and recent status together. Discovery records for the same owned process are hidden from the combined snapshot so one run does not appear twice.

Only the service-owned run can receive a follow-up, interruption, or stop request. A process that merely looks like an agent is evidence for the operator view, not a permission to send input or signals.

References: rust/…/lib.rs• L1-3 rust/…/service.rs• L101-143 rust/…/service.rs• L145-240 rust/…/model.rs• L39-68

Managed run lifecycle

The managed lifecycle turns an operator task into a local CLI turn, reports structured progress, and leaves the run ready for more direction or a clear terminal state. The worker owns the child process and updates the shared run record as output, completion, failure, or cancellation occurs.

This diagram shows how a managed task moves from launch through worker activity and later operator control.

flowchart LR
    A[Operator task] --> B[Managed run accepted]
    B --> C[Worker starts supported CLI]
    C --> D[Structured activity and status]
    D --> E{Turn result}
    E -->|complete| F[Awaiting input or completed]
    E -->|permission or error| G[Needs attention or failed]
    E -->|interrupt or stop| H[Interrupted or stopped]
    F --> I[Follow-up message]
    I --> C

Launch and worker coordination

Launch validation selects a supported harness and an existing project directory before work starts. The task runs with the CLI's normal account, configuration, hooks, and permissions. Swarm sends task text through the managed transport and converts structured CLI output into a small set of operator-facing events.

The worker keeps the run active while a turn is in progress. A later message can wait for the current turn, while interruption clears queued work and stop ends the run. The service also keeps the resident alive while owned runs remain active, so closing the dashboard does not by itself abandon managed work.

References: rust/…/service.rs• L145-240 rust/…/worker.rs• L9-43 rust/…/worker.rs• L131-176 rust/…/process.rs• L29-45

Run control and consistency

Each mutation carries a request identity and the run's current revision. The service can return the same accepted result for a repeated request, while a conflicting request or an old revision is rejected. This lets the dashboard retry an uncertain launch or action without silently starting duplicate work.

The dashboard disables controls when its snapshot is stale. It keeps an accepted result visible until polling catches up, then refreshes from the service's newer state. This prevents delayed reads from making a confirmed action appear lost.

References: rust/…/service.rs• L243-315 rust/…/service.rs• L441-463 dashboard/…/use-swarm.ts• L15-23 dashboard/…/use-swarm.ts• L25-54 dashboard/…/inspector.tsx• L57-79

History and recovery

Swarm keeps a private, bounded summary of managed runs so a restart can show what happened without restoring process authority. The summary does not relaunch tasks, reconnect to a process, restore a session, or expose prompts and output as durable history.

On recovery, active work is represented as interrupted or as another inert terminal summary. The operator must inspect the native CLI transcript before continuing. A new resident epoch also rejects mutations intended for the previous service instance, which prevents stale browser state from controlling a new service.

References: rust/…/history.rs• L6-27 rust/…/history.rs• L30-89 src/…/native_swarm.py• L21-31 rust/…/swarm_op.rs• L60-125

Operator activity views

Dashboard workspace

The dashboard presents one operator view for local agent work. A project rail groups agents by workspace, while map and list views show each agent's harness, task, state, recent activity, and control boundary. Search and attention filters help an operator move from a broad swarm view to the agents that need review.

Selecting an agent opens an inspector with three related views: recent activity, project context, and run details. Managed agents expose instructions, interruption, and stop actions when the service says those actions are valid. Observed agents show an explicit handoff to their own application instead of a misleading control.

References: dashboard/…/swarm-workspace.tsx• L16-32 dashboard/…/swarm-workspace.tsx• L64-92 dashboard/…/agent-map.tsx• L9-29 dashboard/…/inspector.tsx• L84-134

Activity and review signals

Managed activity is a bounded stream of lifecycle, message, command, file, tool, context, permission, and error signals. The dashboard polls it separately from the snapshot and displays recent entries as text. Observed agents show only that the process was seen; their task output remains in the native app.

Pending Guard reviews are shown as project and harness signals. They can belong to another agent in the same project, so the dashboard links them to the existing review interface rather than attributing them to one process.

References: rust/…/run.rs• L18-38 dashboard/…/activity.tsx• L6-35 dashboard/…/inspector.tsx• L105-108

Native and dashboard interfaces

The native resident is the authority for Swarm state and lifecycle. The local HTTP layer exposes a snapshot, launch, action, and event interface to the authenticated dashboard. The dashboard validates replies, preserves the last confirmed snapshot during a disconnect, and marks controls stale until the local service confirms current state.

This interface is local to the Guard dashboard. It does not let hosted views, approval-link sessions, or arbitrary browser input enumerate or control local agents.

References: src/…/swarm_http.py• L1-39 src/…/native_swarm.py• L34-60 rust/…/swarm_op.rs• L35-58 dashboard/…/api.ts• L34-81

Context handoff

Swarm treats project context as a separate capability from agent discovery and run control. The inspector can carry the selected agent, harness, and workspace into the CIGAR context workspace, where the operator chooses files and passes the existing approval step.

The handoff is navigation intent held in the current dashboard tab. Finding a process does not grant context access, enable CIGAR, pair an MCP connection, or prove that an agent used context. Prompt-hook harnesses receive newly approved project context on later prompts when Guard is connected; other harnesses need their own explicit connection and pairing.

The context panel returns the operator to the same agent after setup or preview. It also explains when the selected harness is visible only for activity and cannot receive CIGAR context through Guard.

References: dashboard/…/swarm-handoff.ts• L1-19 dashboard/…/model.ts• L28-38 dashboard/…/inspector.tsx• L109-115 dashboard/…/swarm-context-panel.tsx• L8-40

Swarm connects to the wider dashboard product workspaces, agent and tool integrations, and context assistance broker and workspace workflows through these existing operator and access boundaries.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the managed-versus-observed distinction aligned across discovery records, snapshot parsing, map cards, and inspector controls.
  • Keep request IDs, service epochs, and run revisions consistent across the native service, HTTP framing, dashboard retries, and stale-state handling.
  • Keep event kinds and retention limits aligned between CLI decoding, run activity, event responses, and the activity view.
  • Keep context grants, connection pairing, and reported context use separate when changing Swarm-to-CIGAR navigation or status text.
  • Keep recovery summaries inert when changing persisted fields; never add process, session, task, or control authority to restart state.

Important failure modes

TriggerConsequenceGuard
Dashboard acts on an old epoch or run revisionA stale action could affect newer work or appear to succeed twiceEpoch checks, revision checks, request receipts, and stale-control disabling
Discovery treats an observed process as ownedSwarm could expose control over work it does not superviseObserved agents have no controls; only service-owned runs accept actions
Guard restarts while a run is activePrevious work is not relaunched and the browser may show old stateInert history recovery, new service epoch, and explicit restart notice
Context availability is treated as proof of useOperators could mistake a project grant or token count for agent-level context evidenceSeparate grant, connection, and correlated successful context events
Several agents share one project directoryChanges can conflict even though each run is healthyShow peer agents and require the operator to choose an existing worktree or project boundary

Key files

FileWhy to read it
rust/…/service.rsShows the service-level combination of discovery, managed runs, actions, limits, and worker startup.
rust/…/discovery.rsDefines the boundary between recognized observed processes and managed ownership.
rust/…/worker.rsExplains how a managed turn produces status, activity, completion, failure, and cancellation.
rust/…/history.rsShows what recovery preserves and what it intentionally does not restore.
rust/…/swarm_op.rsShows the resident authority and private history boundary.
src/…/swarm_http.pyShows the local HTTP surface used by the dashboard.
dashboard/…/swarm-workspace.tsxShows the main operator workspace and its project, filter, status, and navigation model.
dashboard/…/inspector.tsxShows agent activity, controls, reviews, details, and context handoff.
dashboard/…/swarm-context-panel.tsxShows how Swarm hands a selected project to CIGAR without granting access implicitly.