StepTransition. Trace capture goes deeper โ it records what happened inside each step: every tool call, thinking block, token count, and cost. The trace is written to a JSONL file during execution, and the file path flows through the workflow journal so analysis tools can find it.
When you need trace capture
- Markov analysis โ fingerprint an agentโs behavioral patterns across runs
- Cost attribution โ break down per-step token usage and cost
- Debugging โ replay exactly what the agent saw, thought, and did
- Regression detection โ compare traces across code changes
Setup
Trace capture requires two things: an agent model that writes trace files, and a workflow client that propagates the path.1. Configure traceDir on ClaudeAgentModel
TheClaudeAgentModel from agent-client writes a JSONL trace file per call() when traceDir is set:
traces/agent-run-20260528-143000-a1b2c3d4.jsonl containing every message in the session.
2. Bridge to a trace-aware AgentClient
The workflow-flowsAgentClient is a @FunctionalInterface that returns text. To carry trace metadata, override executeForResult():
executeForResult() defaults to calling execute() with a null trace path.
3. Use AgentClientStep in a workflow
AgentClientStep gets its own trace file. The path flows through to StepTransition:
How it works
The trace path flows through four layers:TRACE_PATH from context after each step so deterministic steps donโt inherit a stale path.
Journal integration
When usingworkflow-journal, trace paths appear in WorkflowStepEvent and are included in the journalโs JSON output:
tracePath when present:
JDBC persistence
JdbcTraceRecorder stores trace paths in the trace_path column of step_transitions:
ClaudeStep vs AgentClientStep
| ClaudeStep | AgentClientStep | |
|---|---|---|
| Execution | CLI subprocess (claude -p) | In-process via ClaudeAgentModel |
| Trace capture | Not available (text-only output) | Full JSONL trace files |
| Token/cost data | Discarded at process boundary | Available in providerFields |
| Use case | Quick scripts, prototyping | Experiments, production workflows |
AgentClientStep.
Maven coordinates
Related
Durability
JdbcTraceRecorder, CheckpointingStepRunner
API Reference
StepTransition, TraceRecorder, WorkflowExecutor