Wires tracing into atomr-agents workflows: EventBus subscribers, RunTreeBuilder for parent-child run trees, and StdoutTracer/JsonlTracer/LangSmithTracer exporters. Handles RunId/parent_run_id propagation.
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.
Every observable boundary (strategy resolution, tool invocation,
agent turn, workflow step, harness iteration, backpressure) emits a
typed Event. The EventBus broadcasts to subscribers; a
RunTreeBuilder aggregates events into a parent-child run tree;
Tracer exporters consume the tree for downstream sinks
(LangSmith, file, stdout, OpenTelemetry).
Event is the typed taxonomy (StrategyResolved,
ToolInvoked, ToolCallStreamed, AgentTurn, WorkflowStep,
HarnessIteration, Backpressure). ToolCallStreamed fires per
detected tool call before dispatch (live tool intent);
ToolInvoked fires after dispatch (latency / success). AgentTurn
carries reasoning_tokens (o1-style) and cached_tokens
(Anthropic prompt-cache, OpenAI cached input) — both
#[serde(default)] for back-compat.EventEnvelope wraps an event with timestamp_ms,
correlation_id, run_id, parent_run_id, and tags. The
run_id / parent_run_id pair lets a tree builder assemble the
parent-child structure.EventBus is process-local broadcast. Subscribers are
Fn(&EventEnvelope) + Send + Sync + 'static closures.RunTreeBuilder is itself an EventBus subscriber. It
accumulates events into RunNodes indexed by RunId.Tracer + TracerSink is the export plane. Stock sinks:
MemorySink (tests), FileSink (one-line JSONL on disk).use atomr_agents_observability::EventBus;
use atomr_agents_core::{AgentId, Event};
let bus = EventBus::new();
bus.subscribe(|env| {
eprintln!("[{}] {:?}", env.timestamp_ms, env.event);
});
bus.emit(Event::AgentTurn {
agent_id: AgentId::from("a-1"),
input_tokens: 50,
output_tokens: 12,
reasoning_tokens: 0, // populated for o1-style models
cached_tokens: 8, // Anthropic prompt-cache / OpenAI cached input
finish_reason: None,
elapsed_ms: 230,
});
reasoning_tokens and cached_tokens come straight from
atomr_infer_core::tokens::TokenUsage (per-chunk, summed by the
agent into the AgentTurn aggregate). Bill cached tokens at the
provider's cached-input rate (Anthropic: ~10% of normal input;
OpenAI: ~50%) to avoid double-counting them under input_tokens.
ToolCallStreamed and ToolInvoked cover the two halves of a tool
call's lifecycle:
bus.subscribe(|env| match &env.event {
Event::ToolCallStreamed { tool_name, iteration, .. } =>
eprintln!("[stream] iter={iteration} tool={tool_name}"),
Event::ToolInvoked { tool_id, elapsed_ms, ok, .. } =>
eprintln!("[done] tool={} elapsed={elapsed_ms}ms ok={ok}", tool_id.as_str()),
_ => {}
});
use atomr_agents_core::RunId;
let parent = RunId::new();
let child = RunId::new();
bus.emit_run(
Event::AgentTurn { /* ... */ },
parent.clone(),
None, // top-level, no parent_run_id
);
bus.emit_run(
Event::ToolInvoked { /* ... */ },
child,
Some(parent), // child of the agent turn
);
use std::sync::Arc;
use atomr_agents_observability::{EventBus, RunTreeBuilder};
let bus = EventBus::new();
let builder = Arc::new(RunTreeBuilder::new());
builder.clone().attach(&bus);
// … agent / workflow / harness emits events …
let roots = builder.roots(); // top-level RunNodes
let snapshot = builder.snapshot(); // every node by RunId
let one = builder.get(&run_id); // a specific node
Each RunNode has:
pub struct RunNode {
pub run_id: RunId,
pub parent_run_id: Option<RunId>,
pub kind: RunKind,
pub name: String,
pub started_at_ms: i64,
pub ended_at_ms: Option<i64>,
pub tags: Vec<String>,
pub events: Vec<EventEnvelope>,
pub children: Vec<RunId>,
pub error: Option<String>,
}
use atomr_agents_observability::StdoutTracer;
let tracer = StdoutTracer::new(builder.clone());
tracer.flush().await?;
// - agent:a-1 [Agent] 230 ms
// - tool:calc [Tool] 5 ms
// - tool:search [Tool] 22 ms
One JSON-line per node — pipe into jq, log aggregation, or
storage:
use std::sync::Arc;
use atomr_agents_observability::{FileSink, JsonlTracer};
let sink: Arc<dyn atomr_agents_observability::TracerSink> =
Arc::new(FileSink::new("./traces.jsonl"));
let tracer = JsonlTracer::new(builder.clone(), sink);
tracer.flush().await?;
For tests, use the in-memory variant:
let (tracer, mem_sink) = JsonlTracer::in_memory(builder.clone());
tracer.flush().await?;
let lines: Vec<String> = mem_sink.lines.lock().clone();
LangSmith-shaped JSON records (id / name / run_type /
start_time_ms / end_time_ms / parent_run_id / tags /
error / project):
use atomr_agents_observability::LangSmithTracer;
// In tests / offline:
let (tracer, sink) = LangSmithTracer::in_memory(builder.clone(), "my-project");
tracer.flush().await?;
// To ingest into LangSmith proper, write a `TracerSink` impl that
// POSTs each line to the LangSmith API using your `LANGCHAIN_API_KEY`.
The shipped exporter writes one record per RunNode. The
run_type field maps RunKind::{Agent, Workflow, Harness, Chain, Other} → "chain"; Tool / Llm / Retriever / Parser map
1:1.
RunId::new() (UUID-based) for fresh runs.RunId::from("stable-id") when correlating against external
trace ids.(WorkflowId, RunId) keys all checkpoints — see the
atomr-agents-state and atomr-agents-hitl skills for how
state-layer and event-layer correlate.let bus = EventBus::new();
let builder = Arc::new(RunTreeBuilder::new());
builder.clone().attach(&bus);
let agent = Agent { /* ... */, bus: bus.clone(), /* ... */ };
let _ = agent.run_turn(/* ... */).await?;
let tracer = StdoutTracer::new(builder.clone());
tracer.flush().await?;
For multi-agent or workflow scenarios, share the same EventBus
across all Agent / Harness / WorkflowRunner instances — the
run tree fuses by run_id.
use std::sync::Arc;
use parking_lot::Mutex;
let counter = Arc::new(Mutex::new(0u32));
{
let counter = counter.clone();
bus.subscribe(move |env| {
if matches!(env.event, atomr_agents_core::Event::ToolInvoked { .. }) {
*counter.lock() += 1;
}
});
}
flush(). Tracers are lazy — they buffer
in the RunTreeBuilder and emit on flush.bus.emit(...) and bus.emit_run(...) carelessly.
Bare emit produces events with run_id = None; the run tree
builder ignores them.EventBus and expecting separate states. It's an
Arc internally — clones share subscribers.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/atomr-agents-ai-skills:atomr-agents-observabilityfrom 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.