Depute

State Diff

Structured before/after view of state mutations.

Answers: Execution Amnesia, Unpredictable Outcomes, L2 Collaborative.

Install

npx ax-depute@latest add state-diff
pnpm dlx ax-depute@latest add state-diff
yarn dlx ax-depute@latest add state-diff
bunx ax-depute@latest add state-diff

Overview

State Diff provides mutation visibility, turning abstract JSON payloads into human-readable proof of what changed. In high-stakes environments, humans cannot simply trust an agent's summary — they need exact before-and-after deltas.

Interactive StorybookView all states, toggle props, and test edge cases.

Basic Usage

<StateDiff
  title="Configuration Changes"
  entries={[
    { field: 'max_instances', type: 'modified', before: '2', after: '5' },
    { field: 'region', type: 'added', after: 'us-east-1' },
    { field: 'legacy_mode', type: 'removed', before: 'true' },
  ]}
/>

Solution Patterns

Place StateDiff inside a ToolTrace or a PlanCard to show exact intended or completed mutations. Pair it with BindingApproval so the person can see the mutation they are confirming. The signature, if any, comes from your backend.

Props

PropTypeDefaultDescription
titlestring—Title of the diff (e.g. "Database Mutation")
descriptionstring—Optional context
entriesDiffEntry[]—Flat list of diff entries
groupsDiffGroup[]—Grouped entries (takes precedence over entries)
hideUnchangedbooleanfalseHide unchanged fields
defaultCollapsedbooleanfalseStart collapsed
timestampstring—Mutation timestamp
sourceIdstring—Tool call/step ID

Design rationale

Why hideUnchanged? Massive JSON payloads distract from the actual mutation. Highlighting only the delta reduces cognitive load and focuses human attention exactly where the risk is.

Why structure over syntax highlighting? A human cannot easily parse a raw git-style diff of a minified JSON object. Transforming the delta into a structured, dot-notated table makes the blast radius legible to non-engineers.

On this page