WorkStreams
Durable, observable multi-step work. Archie orchestrates it and your agent calls it by name.
The same surface serves declarative pipelines and long-running agentic jobs.
Four Nouns, One Hierarchy
One execution is called a cycle, never a "run". The REST API publishes Workplans at /api/v1/workstreams/workplans/{workplan_id}. The older /blueprints and /jobs paths still answer, as deprecated aliases.
A reusable template. Written once, run many times.
A WorkStream bound to a client and jurisdiction, its inputs fixed across cycles.
One execution of a Workplan. May pause for approval; ends completed, failed or cancelled.
One step in a cycle. Tasks run in the order the WorkStream's step graph sets.
execution_mode
Every WorkStream has an execution_mode and the runtime branches on it. workstream.draft authors inline WorkStreams only: containerized authoring is retired, and a step that needs an agent loop is written as an agent_run step.
Declarative steps, fast start. Suits close, reconciliations and journal posting.
Agentic and longer-running, with a full Python and Pandas stack alongside. Existing containerized WorkStreams still run; new ones are not drafted this way.
Draft, Commit, Run, Watch, Advance
Author a WorkStream once, commit it, then run a cycle per period and client. Watch the cycle's events and approve, pause, resume or cancel as needed.
# 1. Author a WorkStream (once)
POST https://uk.heyarchie.com/api/v1/skills/workstream.draft/invoke
{ "description": "Monthly close for SaaS clients with deferred revenue", "target_execution_mode": "inline", "draft_key": "monthly-close-saas" }
# returns { "draft_id": "..." }, or { "draft_id": null, "question": "..." } when Archie needs
# one answer first: answer it in the next workstream.draft call, with the same draft_key
# and the frames you got back passed in thread
# 2. Commit the draft to make it executable
POST https://uk.heyarchie.com/api/v1/skills/workstream.commit/invoke
{ "draft_id": "...", "scope": "firm", "name": "monthly-close-saas" }
# returns { "workstream_id": "...", "permakey": "abc1234", "status": "active" }
# 3. Run a cycle (per period, per client)
POST https://uk.heyarchie.com/api/v1/skills/workstream.run/invoke
{ "workstream_id": "abc1234", "client_id": "...", "period": "FY26-Q1",
"runtime_vars": { "include_deferred": true },
"idempotency_key": "close-2026-04-acme-001" }
# returns { "cycle_id": "...", "status": "pending", "events_url": "/api/v1/workstreams/cycles/{id}/events" }
# 4. Watch it run (SSE: live event stream)
GET https://uk.heyarchie.com/api/v1/workstreams/cycles/{cycle_id}/events
# 5. Approve, pause, resume or cancel as needed
POST https://uk.heyarchie.com/api/v1/skills/workstream.advance/invoke
{ "cycle_id": "...", "action": "approve_task", "task_id": "..." }A step marked requires_approval moves the cycle to awaiting_approval when it completes. The cycle waits until the caller sends workstream.advance with action: "approve_task", then resumes in place. Nothing is run again.
skip_step marks a task skipped and moves on. Use it sparingly: a skipped step produces no outputs, so a later step that reads them gets a Jinja ChainableUndefined, which renders as an empty string. Prefer cancelling and running again with a corrected WorkStream.
The Live Event Stream
Every cycle streams events at GET https://uk.heyarchie.com/api/v1/workstreams/cycles/{cycle_id}/events as standard SSE, each with an event: name and a JSON data: line. The stream opens with a snapshot of the cycle's steps so far, sends a patch for each step that changes, sends keepalive while it waits, and ends with done once the cycle finishes. Each snapshot and patch carries items: the steps, each with its label and status.
import time
from heyarchie import Archie, ArchieNotFoundError
client = Archie(api_key=API_KEY, base_url="https://uk.heyarchie.com")
run = client.skills.workstream_run(workstream_id="month-end-close", client_id=CLIENT_ID, period="FY26-Q1")
cycle_id = run["output"]["cycle_id"]
for attempt in range(5):
try:
for chunk in client.workstreams.cycles.stream_events(cycle_id):
if chunk.event in ("snapshot", "patch"):
for step in chunk.data["items"]:
print(step["label"], step["status"])
elif chunk.event == "done":
print("cycle done")
break
break
except ArchieNotFoundError:
time.sleep(2) # a just-started cycle can take a few seconds to appearEvery write (workstream.run, workstream.cancel, workstream.advance, workstream.draft, workstream.commit) takes an optional idempotency_key. Pick any stable string under 200 characters. Sending it again within 24 hours returns the original cycle id instead of starting a duplicate. Use one in any automated retry loop.
workstream.list returns up to limit rows (default 20, max 100) in items, with total and a next_cursor. Pass next_cursor back as cursor to read the next page. The REST list routes, such as GET https://uk.heyarchie.com/api/v1/workstreams/workplans, page with limit and offset instead and return a pagination object with total, limit, offset and has_more.
The Error Envelope
WorkStream skill outputs carry the standard error envelope in error_envelope. Branch on code, never on message: codes are stable across releases. retryable: true means you can safely send the same request again, with the same idempotency_key. The older error string stays filled in for now, but new code should read error_envelope.
{
"skill": "workstream.run",
"output": {
"cycle_id": null,
"run_id": null,
"status": "pending",
"execution_mode": "inline",
"events_url": "",
"detail_url": "",
"error": "not_found",
"error_envelope": null
},
"correlation_id": "1746d32a-…"
}