Designs and modifies channelled state for atomr-agents: declares StateSchema, picks reducers (LastWriteWins, AppendMessages, MergeMap, etc.), persists via Checkpointer, and forks divergent runs.
Ships in atomr-agents-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
agents-state is the framework's stateful-graph layer. State is a
typed map of channels; each channel has a reducer that merges
existing values with incoming writes; checkpoints persist after
every super-step so workflows resume cleanly after a crash and
operators can fork divergent runs.
(key, reducer, default).RunId from any prior checkpoint with
optional state edits applied at the fork point.| Reducer | Picks when |
|---|---|
LastWriteWins | scalar config / phase / current step pointer |
AppendList | event log, observations, audit trail |
AppendMessages | chat history with idempotent retry — appends new ids, replaces same id |
MergeMap | structured config, partial settings, accumulated metadata |
MaxByTimestamp | sensor / heartbeat values — newer write wins by ts_ms field |
Custom reducer:
use atomr_agents_state::Reducer;
struct Sum;
impl Reducer for Sum {
fn reduce(&self, current: serde_json::Value, incoming: serde_json::Value) -> serde_json::Value {
let a = current.as_i64().unwrap_or(0);
let b = incoming.as_i64().unwrap_or(0);
serde_json::json!(a + b)
}
}
Reducers must be associative; they don't need to be commutative.
use std::sync::Arc;
use atomr_agents_state::{
AppendMessages, MaxByTimestamp, MergeMap, RunState, StateSchema,
};
let schema = Arc::new(
StateSchema::builder()
.add("messages", AppendMessages)
.add("config", MergeMap)
.add_lww("phase") // shorthand for LastWriteWins
.add("heartbeat", MaxByTimestamp)
.add_with_default(
"counter",
crate::Sum,
serde_json::json!(0),
)
.build(),
);
let mut state = RunState::new(schema);
// Single write through the channel's reducer.
state.write("messages", serde_json::json!([{"id": "m1", "text": "hi"}]))?;
// Batch (one super-step's worth of writes).
state.merge_writes(vec![
("config".into(), serde_json::json!({"feature_x": true})),
("messages".into(), serde_json::json!([{"id": "m2"}])),
])?;
// Reads.
let msgs = state.read("messages");
assert_eq!(state.super_step(), 0); // hasn't been advance()d yet
write to an unknown channel errors — schema is the source of
truth.
use std::sync::Arc;
use atomr_agents_state::{Checkpointer, InMemoryCheckpointer};
let cpt: Arc<dyn Checkpointer> = Arc::new(InMemoryCheckpointer::new());
For production, use a backend feature flag:
[dependencies]
atomr-agents-state = { version = "0.2", features = ["sqlite"] }
# or "postgres"
use atomr_agents_state::SqliteCheckpointer;
let cpt: Arc<dyn Checkpointer> = Arc::new(
SqliteCheckpointer::connect("sqlite://./checkpoints.db").await?,
);
(SQLite/Postgres ship as feature-gated stubs in the open-source
crate; wire to sqlx in your deployment patch.)
use atomr_agents_workflow::{Dag, FnStatefulStep, StatefulRunner, StatefulStep};
use atomr_agents_core::{RunId, WorkflowId};
let dag: Dag<Arc<dyn StatefulStep>> = Dag::builder("a")
.step("a", Arc::new(FnStatefulStep(|_state| async {
Ok(vec![("messages".into(), serde_json::json!([{"id": "m1"}]))])
})))
.step("b", Arc::new(FnStatefulStep(|state| {
let n = state.read("messages").as_array().map(|v| v.len()).unwrap_or(0);
async move { Ok(vec![("config".into(), serde_json::json!({"seen": n}))]) }
})))
.edge("a", "b")
.build();
let runner = StatefulRunner {
workflow_id: WorkflowId::from("wf-1"),
run_id: RunId::from("run-1"),
dag,
schema,
checkpointer: cpt.clone(),
};
let final_state = runner.run().await?;
If the process dies and restarts with the same (workflow_id, run_id), the runner reads the latest checkpoint and resumes from
the next un-executed super-step. Side-effecting steps (counter
increments, external API calls) only fire once.
use atomr_agents_state::CheckpointKey;
let new_run = cpt.fork(
&CheckpointKey {
workflow_id: WorkflowId::from("wf-1"),
run_id: RunId::from("run-1"),
super_step: 2,
},
vec![
("config".into(), serde_json::json!({"feature_x": true})),
],
).await?;
fork is the substrate for time-travel debugging, the
POST /runs/:id/fork Studio endpoint, and Command::Update during
HITL resume.
docs/state-and-checkpointing.mdcrates/state/src/reducer.rscrates/state/src/checkpointer.rscrates/workflow/src/state_runner.rsLastWriteWins for chat history. Parallel branches will
clobber each other. Use AppendMessages.RunId on resume. (workflow_id, run_id) keys the
checkpoint. Different RunId = fresh run, no resume.state.advance() between super-steps. Manual
driving requires it; StatefulRunner does it for you.Checkpointer::fork
errors. Inspect with list(workflow, run) first.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/atomr-agents-ai-skills:atomr-agents-statefrom atomr-agents-ai-skills
npx claudepluginhub rustakka/atomr-agents --plugin atomr-agents-ai-skills14 skills in this plugin
/atomr-agents-evalUse when writing eval suites, picking a `Scorer` (Contains / LlmJudge / Rubric / Pairwise), gating publication on `RegressionGate`, queuing items for human annotation, or wiring online eval. Triggers on `EvalSuite { ... }`, `EvalSuite::run`, `LlmJudgeScorer::new`, `PairwiseScorer::compare`, `RegressionGate::check`, or `Registry::publish_gated`./atomr-agents-hitlUse when adding human-in-the-loop pause/resume — dynamic `interrupt()` from a step, static breakpoints (`interrupt_before` / `interrupt_after`), or driving resume with `Command::{Continue, Resume, Update, Goto}`. Triggers on writing `Interruptible { ... }`, calling `ctrl.interrupt(...)`, or porting a LangGraph `interrupt()` / `Command(resume=...)` flow./atomr-agents-langgraph-migrationUse when porting LangGraph or LangChain code to atomr-agents — translating `StateGraph` / `Runnable` / `RunnableSequence` / `MemorySaver` / `interrupt` / `Command` / `ToolNode` / retriever zoo / output parsers / `create_agent` middleware. Triggers on porting an existing LangChain / LangGraph project, or asking "how do I do X from LangGraph in atomr-agents"./atomr-agents-meetings-harnessUse when turning a diarized STT transcript into structured meeting artifacts in atomr-agents — building a `MeetingsHarness`, accumulating a `MeetingAnalysis` (attendees, notes, actions-with-owners, tiered summaries), picking batch vs live mode, persisting via the configured `Checkpointer` under the same `conversation_id` as the source transcript, or serving the meetings review UI (`meetings-harness-web`). Triggers on `MeetingsHarness`, `MeetingAnalysis`, "extract action items", "meeting summary", "attendees from transcript", "live meeting analysis", `atomr_agents.meetings_harness`./atomr-agents-middlewareUse when wrapping the agent's per-turn pipeline with cross-cutting policies — logging, retry, rate-limit, redaction, tool-error recovery, dynamic prompt override, before/after hooks. Triggers on `impl AgentMiddleware for`, `MiddlewareStack::new().push(...)`, or porting a LangChain `create_agent` middleware (`@wrap_model_call` / `@wrap_tool_call` / `@dynamic_prompt`)./atomr-agents-multi-agentUse when wiring an `Org` / `Department` / `Team` topology, picking a routing strategy (`RoundRobin` / `LoadAware` / `CapabilityMatch`), or building a supervisor / swarm / network / hierarchical multi-agent pattern. Triggers on `Team { unit: OrgUnit { ... } }`, `swarm_loop(...)`, `HandoffTool::new(...)`, `Policy::narrow`, or porting a LangGraph supervisor.