Stately
PackagesAgent

Scope and ecosystem boundaries

What Stately Agent owns, what the host owns, and where specialized libraries fit.

Alpha: @statelyai/agent 2.0 is in alpha. APIs can change between releases; pin an exact version. Feedback: github.com/statelyai/agent.

@statelyai/agent is a portable control-flow tool, not an agent framework. It owns the executable machine: states, legal transitions, typed requests, decisions, composition, suspension, resume, and deterministic testing. The host owns every external capability.

That boundary is what makes a machine portable. Agent frameworks that bundle a model client, a search client, a memory store, and a server all at once tie your control flow to those choices. Here the machine only ever describes work; the host decides how it happens, so the same machine runs against a different SDK, provider, or database with no edits.

In practice the machine says what:

searching: {
  invoke: { src: "searchWeb", input: ({ context }) => ({ query: context.query }) },
}

and the host says how, binding searchWeb to whichever search client, cache, and auth it uses.

Ownership boundary

ConcernOwnerStately Agent integration point
Workflow states, branching, loops, parallelism, retries, approval gatesMachineXState machine configuration
Model calls and structured outputHost or model SDKAgentRequestExecutors
Tools and tool loopsHost or model SDKrequest tools and metadata
Search, RAG, crawling, data APIsSpecialized library or servicetool, executor, or actors implementation
Long-term and semantic memoryDatabase or memory libraryload into machine input; expose reads/writes as actors or tools
Sandboxes, filesystems, generated artifactsSandbox or workspace libraryhost actors and artifact handles in machine context
MCP discovery, auth, sessions, and transportMCP client or host frameworkpass discovered tool descriptors into requests
Evaluation datasets, scorers, experiments, and dashboardsEvaluation libraryconsume onTrace, onResult, snapshots, and machine outputs
Snapshot persistenceHost storeAgentSnapshotStore and persistSnapshot(...)
Queues, schedules, leases, deployment, HTTP/SSE/WebSocketRuntime or application frameworkstep API, snapshots, callbacks, emitted events
Telemetry exportObservability libraryonTrace and inspect

The repository includes examples for the orchestration shape, not replacement implementations of those systems:

  • Deep research models planning, concurrent research, reflection, and synthesis. Its search implementation still belongs to the host.
  • Trading team models parallel analysts, debate, risk review, and approval. Market feeds and order execution remain external.

Core criteria

A feature belongs in core when portable machine intent cannot otherwise be expressed or handed to an arbitrary host without framework-specific glue. Good core candidates improve one of these seams:

  • authoring typed, inspectable control flow;
  • describing external work without executing it;
  • binding that work in any host;
  • suspending, persisting, and resuming without changing the machine;
  • stepping and replaying deterministically;
  • observing a run without coupling it to one telemetry or evaluation vendor.

A feature does not belong in core merely because popular agent applications need it. Search clients, vector stores, browser automation, code sandboxes, skills, prompt registries, eval scorers, and deployment servers are useful precisely because specialized libraries can evolve them independently.

Integration recipes

  • Wrap an async capability as an XState actor and provide it through actors.
  • Pass SDK-native tools through a request's tools map.
  • Put host-only hints in request metadata; core preserves it without interpreting it.
  • Close over auth, tenant, tracing, and service clients when constructing executors or actors.
  • Persist JSON-safe snapshots and external artifact handles, not live clients or binary resources, in machine context.
  • Feed traces to an evaluation or observability library through onTrace; do not make the machine aware of the destination.

On this page