StepDebugger
Step through agent execution one step at a time for debugging and inspection.
Usage
import { createTestHarness, createMockLLM } from '@ahzan-agentforge/core';
const harness = createTestHarness({ agent: myAgentConfig, llm: mockLLM });
const debugger = await harness.startDebug({ task: 'Process order' });StepDebugger Interface
interface StepDebugger {
next(): Promise<DebugStep>; // Execute one step
finish(): Promise<TestResult>; // Run remaining steps
state(): DebugState; // Current state
isDone(): boolean; // Check if complete
}DebugStep
interface DebugStep {
step: StepRecord;
state: DebugState;
done: boolean;
}DebugState
interface DebugState {
runId: string;
status: RunStatus;
messages: Message[];
stepCount: number;
steps: StepRecord[];
totalTokens: number;
}Step-by-Step Debugging
const dbg = await harness.startDebug({ task: 'Process order' });
// Step 1
const step1 = await dbg.next();
console.log(step1.step.type); // 'llm'
console.log(dbg.state().stepCount); // 1
// Step 2
const step2 = await dbg.next();
console.log(step2.step.toolCall?.name); // 'create-order'
// Inspect state at any point
const state = dbg.state();
console.log(state.messages);
console.log(state.totalTokens);
// Finish remaining steps
if (!dbg.isDone()) {
const result = await dbg.finish();
console.log(result.status);
}Use Cases
- Debugging unexpected behavior — step through and inspect state at each point
- Verifying tool call order — ensure tools are called in the right sequence
- Testing approval flows — pause at the right step and verify pending approvals
Next Steps
- Recipes — common test patterns
- TestHarness — test runner