Agent Workflow

Update the diagram after a merge: three calls, and how to pick one

By the engineer who builds Datadef, from client work on data platforms · Reviewed August 21, 2026

A branch lands, the architecture picture is now one service behind, and nobody notices until the next incident review. An agent connected to your diagrams can close that gap in a single call. The catch is that there are three different calls it could make, they are not interchangeable, and picking the wrong one is how teams end up with a diagram that quietly reshuffles itself every day.

7 min readFor teams whose diagram is always one merge behind the code

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

160/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Most merges should not touch the diagram

A repository at a normal pace produces dozens of commits a week and a handful of architectural changes a quarter. A README fix, a test, a dependency bump, a comment: none of them change what the picture shows. A loop that redraws on every merge spends time and tokens producing a diagram identical to the one it replaced, or worse, subtly different because the model made different choices the second time around.

Datadef settles that question before drawing anything. A sync first resolves the head commit of the tracked ref and stops there if it has not moved. If it has, it computes a structure fingerprint, a truncated SHA-256 over what actually feeds the diagram: the parsed Terraform draw plan for a Terraform repository, the assembled file corpus for everything else. A commit that touches a README, a test or a comment moves the commit sha and not the fingerprint, and a sync whose fingerprint has not moved skips generation outright. No model call, no redraw, no new version.

That changes what a sensible default looks like. An agent can call the refresh after every merge without paying for the merges that did not matter. The no-op answer comes back in a couple of seconds and is literal about it: already up to date, the repository and ref it checked, and the commit it is still sitting on.

The three calls, and what each one costs

edit_diagram takes one plain-language instruction against one diagram, applies it, and returns a PNG of the result. It is the right call when the change is small and you already know exactly what it is: one new service, one rewired arrow, one renamed table. It spends a generation credit, and when the model concludes that nothing needed to change, the credit is refunded and you get a note saying so instead of a redraw.

repo_refresh takes a project id and re-syncs the linked repository. It is the right call when the branch has moved and you want the picture to follow the source rather than your description of it. It is also the destructive one: a real sync regenerates the diagram from the repository and replaces manual canvas edits. The call waits about ten seconds for the fast path, then reports that the sync is running and points the agent at repo_status. Refreshes are rate limited to ten in ten minutes per account, so an agent looping over twenty projects queues instead of starting twenty generations at once.

The third call is no call. Daily sync already runs about once a day per linked diagram while it is enabled. If the merge was not urgent, the loop is covered and the correct agent behaviour is to say that rather than to burn a generation proving it.

> we merged the events consumer, is the platform diagram current?

repo_status(project_id: "prj_8fd2")
  "Platform" tracks github acme/platform (branch main).
  Sync: synced 20 hours ago, status ok, at commit 4f1c9a2b1d.
  Daily sync is on.

repo_refresh(project_id: "prj_8fd2")
  Sync started. The diagram is being regenerated from acme/platform
  (branch main); this usually takes 1 to 3 minutes.

Why a regenerated diagram does not reshuffle

The reason teams stop trusting automatic regeneration is rarely accuracy. It is that the second version looks like a different diagram: new names, new zones, everything in a new place, and the one node someone had dragged somewhere meaningful is back in the middle of the canvas.

Three mechanisms hold the picture still. On a re-sync the previous diagram is handed back to the model as grounding: its zones, and up to 60 of its nodes as id, label, type and zone, under rules that say anything still present in the source keeps all four, and that zones are not to be renamed, re-split or rearranged. Node identity travels as a source id recorded on each node rather than being reconstructed from the label, so a rename stays a relabel instead of becoming a new node. And nodes a person dragged are pinned: the sync records where it left every node, and anything sitting more than 12 pixels from that spot at the next run is treated as a deliberate move and put back.

The threshold is what makes that safe to leave on. A node still sitting where the layout engine put it is not pinned, so an untouched diagram stays free to re-lay out as it grows, while a hand-arranged one holds still. The grounding block is also appended only on a re-sync of an existing diagram: a first generation, a scratch canvas, a dashboard prompt and a plain MCP call all draw freely. Each sync then logs what share of the previous node ids survived, which is the number to look at when a small source change produced a large diagram change.

The half a merge does not contain

A merge tells you what the code now does. It does not tell you that the old path is deprecated but still serving traffic, that the new queue is temporary until the migration finishes, or that a service exists for one customer and comes out in November. Those are the sentences a reader actually needs, and no amount of reading the diff produces them.

So the division of work is stable: the agent handles the structural half, which is mechanical and verifiable against source, and a person writes the annotations that carry intent. Annotations survive a sync when they are notes on the canvas rather than the shape of the drawing itself. Nodes added by hand are counted separately in the grounding handed to the next generation, with an explicit instruction to keep them, because they are the reader's own work and nothing in the source will ever justify them.

Where the loop actually breaks

Not the drawing. The trigger. A loop nobody invokes is the same as no loop, which is why the post-merge instruction belongs in the file your agent reads every session. See agent rules for diagram tools.

FAQ

Should an agent regenerate the architecture diagram after every merge?

It can, as long as no-op work is skipped. Datadef computes a structure fingerprint on each sync and skips regeneration entirely when that fingerprint has not moved, so a README or test-only commit costs nothing and changes nothing. The only real judgment call is on diagrams that were hand-tuned, because a re-sync regenerates from source and replaces manual canvas edits.

What is the difference between editing a diagram and re-syncing it?

An edit applies one described change to the existing canvas and leaves everything else alone. A re-sync re-reads the repository and regenerates the diagram from source, which is more faithful to the code and replaces manual canvas edits. Use the edit for a small change you can name, the re-sync when the source has moved and should be the authority.

Will the diagram look different after a re-sync?

Only where the source changed. On a re-sync the previous ids, labels and zones are handed to the model with instructions to reuse them for everything that still exists, and zones are not renamed or re-split between runs. Any node sitting more than 12 pixels from where the last sync left it counts as a hand move and is restored to that position, while nodes still on their computed coordinates stay free to re-lay out.

Can an agent trigger the sync, or does it have to happen in the app?

Either. The repo_refresh tool triggers a sync from any connected MCP client such as Claude Code or Cursor, and the repositories page has a manual refresh button. Daily sync runs on its own while the link is enabled. Only the owner of the repository connection can refresh it.

What happens if two agents refresh the same project at once?

Nothing harmful. A sync of a single link is deduplicated, so the second call joins the run already in progress instead of starting a competing one, and refreshes are rate limited to ten in ten minutes per account. A loop across many projects therefore queues rather than fanning out into a dozen simultaneous minutes-long generations.