Depute Logo

State Diff

Structured before/after view of state mutations.

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.

4 changes
max_instances25max_instances: Modified from 2 to 5
auto_scalingfalsetrueauto_scaling: Modified from false to true
regionus-east-1region: Added value us-east-1
legacy_modetruelegacy_mode: Removed value true
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. It is typically paired with BindingApproval to prove what the user is cryptographically signing off on prior to execution.

Props

PropTypeDefaultDescription
titlestringTitle of the diff (e.g. "Database Mutation")
descriptionstringOptional context
entriesDiffEntry[]Flat list of diff entries
groupsDiffGroup[]Grouped entries (takes precedence over entries)
hideUnchangedbooleanfalseHide unchanged fields
defaultCollapsedbooleanfalseStart collapsed
timestampstringMutation timestamp
sourceIdstringTool 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