---
title: "Record every step of every run · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-features/agents-in-products/agent-run-trace
updated: 2026-10-20
licence: "All rights reserved"
---

# Record every step of every run

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Agents in products](https://agentwranglers.se/playbook/ai-features/agents-in-products)
- Rule: Store each step of an agent run with its tool name, arguments, a short result, the time and the cost. Let support and the user see what the agent did.
- How: Give each run an ID and write one row per step. Mask personal data in arguments and results, as for [prompt text](https://agentwranglers.se/playbook/ai-features/logs-privacy-and-feedback/prompt-text-retention). Show users a plain list of the actions taken for them, with undo. The method is in [log agent actions and let users undo them](https://agentwranglers.se/playbook/adversarial-testing/hostile-agents-and-bots/reversible-agent-actions). Tracing standards, such as the OpenTelemetry semantic conventions for generative AI, let common tools display the steps.
- Check: Run a test task with three tool calls. The run's trace has three step rows with tool, arguments, result, time and cost. The user's activity page lists the same actions.

Example:

```ts
await db.agentSteps.insert({ runId: run.id, step, tool: call.name, args: maskPersonalData(JSON.stringify(call.args)),
  resultSummary: maskPersonalData(summarise(result)).slice(0, 500), costUsd, at: new Date() });
```

```python
db.agent_steps.insert(run_id=run.id, step=step, tool=call.name, args=mask_personal_data(json.dumps(call.args)),
                      result_summary=mask_personal_data(summarise(result))[:500], cost_usd=cost_usd, at=datetime.now(UTC))
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers ai features playbook: https://agentwranglers.se/playbook/ai-features/agents-in-products/agent-run-trace`.

- Previous: [End every agent run with a known status](https://agentwranglers.se/playbook/ai-features/agents-in-products/agent-run-status)
- Next: [Let runs pause and resume](https://agentwranglers.se/playbook/ai-features/agents-in-products/resumable-agent-runs)
- [Agents in products](https://agentwranglers.se/playbook/ai-features/agents-in-products)
