Steps
Step records — the building blocks of agent execution traces.
StepRecord
Each iteration of the agent loop produces a step record:
interface StepRecord {
index: number; // 0-based step number
type: 'llm' | 'tool'; // What happened in this step
startedAt: number; // Timestamp (ms)
duration: number; // Time taken (ms)
tokens: {
input: number;
output: number;
};
toolCall?: {
name: string;
input: unknown;
output: unknown;
error?: string;
};
error?: string;
}Accessing Steps
From a run result:
const result = await agent.run({ task: 'Do something' });
for (const step of result.trace.steps) {
console.log(`Step ${step.index}: ${step.type}`);
console.log(` Duration: ${step.duration}ms`);
console.log(` Tokens: ${step.tokens.input}/${step.tokens.output}`);
if (step.toolCall) {
console.log(` Tool: ${step.toolCall.name}`);
if (step.toolCall.error) {
console.log(` Error: ${step.toolCall.error}`);
}
}
}Step Types
llm— an LLM call was made.tokensreflects the usage.tool— a tool was executed.toolCallcontains the details.
A single agent loop iteration may produce both an LLM step (the LLM deciding to call a tool) and one or more tool steps (the actual executions).
Trace Summary
The trace summary aggregates step-level data:
const { summary } = result.trace;
// summary.totalSteps
// summary.totalTokens
// summary.totalDuration
// summary.toolCalls (count)