AgentForge

Trace Formatting

Format traces for human-readable output — step lines, run summaries, and full traces.

Formatting Functions

import {
  formatStepLine,
  formatRunStart,
  formatRunComplete,
  formatFullTrace,
} from '@ahzan-agentforge/core';

formatStepLine

Format a single step as a one-line summary:

const line = formatStepLine(step);
// "Step 3: tool call search({query: 'pricing'}) → 2 results (450ms)"

formatRunStart

Format the start of a run:

const header = formatRunStart(runId, agentName, task);
// "═══ Run run_abc123 ═══\nAgent: my-agent\nTask: Find pricing info"

formatRunComplete

Format the completion of a run:

const footer = formatRunComplete(result);
// "═══ Completed ═══\n5 steps, 12,345 tokens, $0.02, 3.2s"

formatFullTrace

Format the entire trace for display:

const output = formatFullTrace(trace);
console.log(output);
// Full formatted trace with header, all steps, and summary

Next Steps

  • Replay — diff and replay runs
  • Traces — building traces