Input A Mermaid only
flowchart TD
request[Request] --> auth{Authorized?}
auth -->|yes| api(API)
auth -->|no| reject[Reject]Agent must reconstruct:
- which node branches
- the two possible terminal paths
- what shape and arrows do—or do not—mean
Mermaid in · graph2agent · explicit context out
graph2agent turns Mermaid diagrams into explicit text for coding agents. Keep the diagram for people; add deterministic context that spells out the elements, connections, branches, order, topology, and what the notation does not prove. Humans can scan the picture visually; an agent receiving only Mermaid source must reconstruct those relationships from compact syntax.
In one frozen paired benchmark, adding that text cut exact-comprehension failures from 121 to 60.
diagram + generated contextagent context on
```mermaid
flowchart TD
request[Request] --> auth{Authorized?}
auth -->|yes| api(API)
auth -->|no| reject[Reject]
```Exact interpreted-v3 agent context · v0.4.0
Diagram contract
Type: Mermaid flowchart.
Layout direction: top to bottom. This controls presentation and does not by itself declare execution order.
The diagram contains 4 elements, 3 explicit relationships, 0 ordered events, 0 groups, and 0 notes.
Elements
- `Request` is a rectangle.
- `Authorized?` uses the "decision" shape.
- `API` uses the "rounded" shape.
- `Reject` is a rectangle.
Connections
- `Request` points to `Authorized?` with an arrow.
- `Authorized?` points to `API` with an arrow labeled "yes".
- `Authorized?` points to `Reject` with an arrow labeled "no".
Direct connection summary
- `Request`: incoming from none; outgoing to `Authorized?`.
- `Authorized?`: incoming from `Request`; outgoing to `API` and `Reject`.
- `API`: incoming from `Authorized?`; outgoing to none.
- `Reject`: incoming from `Authorized?`; outgoing to none.
Derived topology
- Elements with no incoming directed connections: `Request`.
- Elements with no outgoing directed connections: `API` and `Reject`.
- Branch candidates, based only on multiple outgoing directed connections: `Authorized?`.
- Merge candidates, based only on multiple incoming directed connections: none.
- Weakly connected components: [`API`, `Authorized?`, `Reject`, and `Request`].
- Directed cycles, shown as strongly connected element sets: none.
Meaning and limits
- Recognized Mermaid or UML markers are modeling cues. Other kinds, styles, and presentation do not establish executable behavior or unstated rules. Color, placement, and styling are presentation unless explicitly labeled as contract semantics. Layout direction is presentation, not execution order. Missing links are unspecified, not forbidden. A conventional reading never overrides explicit local structure.
- Only authored explicit shapes receive roles: `Request` has an authored rectangle, commonly read as a process step; `Authorized?` has an authored decision, commonly read as a point where outgoing paths represent alternatives; `API` has an authored rounded, commonly read as an event; `Reject` has an authored rectangle, commonly read as a process step. Mermaid guarantees those shapes, not runtime components, boolean evaluation, persistence, or execution; implicit rectangles and label-only metadata do not become processes.
- A one-way connector records source-to-target direction without execution timing.
- Connector labels are literal contract text without normalization or evaluation.
- Shape cues guide interpretation but alone define no executable behavior.
- Branch and merge candidates are topology observations, not proof of decision or synchronization semantics.Why agents need the text
Mermaid compresses many relationships into a few lines. As diagrams gain branches, loops, and participants, graph2agent expands the authored structure into explicit text while preserving the original diagram.
Input A Mermaid only
flowchart TD
request[Request] --> auth{Authorized?}
auth -->|yes| api(API)
auth -->|no| reject[Reject]Agent must reconstruct:
Input B Mermaid + graph2agent interpreted-v3
Diagram contract
Type: Mermaid flowchart.
Layout direction: top to bottom. This controls presentation and does not by itself declare execution order.
The diagram contains 4 elements, 3 explicit relationships, 0 ordered events, 0 groups, and 0 notes.
Elements
- `Request` is a rectangle.
- `Authorized?` uses the "decision" shape.
- `API` uses the "rounded" shape.
- `Reject` is a rectangle.
Connections
- `Request` points to `Authorized?` with an arrow.
- `Authorized?` points to `API` with an arrow labeled "yes".
- `Authorized?` points to `Reject` with an arrow labeled "no".
Direct connection summary
- `Request`: incoming from none; outgoing to `Authorized?`.
- `Authorized?`: incoming from `Request`; outgoing to `API` and `Reject`.
- `API`: incoming from `Authorized?`; outgoing to none.
- `Reject`: incoming from `Authorized?`; outgoing to none.
Derived topology
- Elements with no incoming directed connections: `Request`.
- Elements with no outgoing directed connections: `API` and `Reject`.
- Branch candidates, based only on multiple outgoing directed connections: `Authorized?`.
- Merge candidates, based only on multiple incoming directed connections: none.
- Weakly connected components: [`API`, `Authorized?`, `Reject`, and `Request`].
- Directed cycles, shown as strongly connected element sets: none.
Meaning and limits
- Recognized Mermaid or UML markers are modeling cues. Other kinds, styles, and presentation do not establish executable behavior or unstated rules. Color, placement, and styling are presentation unless explicitly labeled as contract semantics. Layout direction is presentation, not execution order. Missing links are unspecified, not forbidden. A conventional reading never overrides explicit local structure.
- Only authored explicit shapes receive roles: `Request` has an authored rectangle, commonly read as a process step; `Authorized?` has an authored decision, commonly read as a point where outgoing paths represent alternatives; `API` has an authored rounded, commonly read as an event; `Reject` has an authored rectangle, commonly read as a process step. Mermaid guarantees those shapes, not runtime components, boolean evaluation, persistence, or execution; implicit rectangles and label-only metadata do not become processes.
- A one-way connector records source-to-target direction without execution timing.
- Connector labels are literal contract text without normalization or evaluation.
- Shape cues guide interpretation but alone define no executable behavior.
- Branch and merge candidates are topology observations, not proof of decision or synchronization semantics.Structure and limits are explicit
Illustrative compilation example; the measured study is reported below.
+18.48pp
exact contract-comprehension lift in one frozen, paired benchmark of330 private contracts
One compiler, four launch surfaces
Core v0.4.0, Action v0.4.0, Homebrew, and direct Debian downloads are public. MCP v0.4.0 is live through npm on macOS and Linux; native Windows downloads are live on GitHub, while one-command npm activation on Windows is pending. The signed APT repository is staged but not live.
Install with Homebrew or a verified amd64 or arm64 Debian package. Paste one diagram for rich text on stdout, or put the repository update after your existing generators.
brew install graph2agent/tap/graph2agent
graph2agent describe --profile interpreted-v3 -
make generateOn macOS and Linux, the live npm package gives an MCP-capable agent the tool without a manual native download. Windows users can use the verified native executables from the v0.4.0 GitHub release; one-command npm activation on Windows is pending.
npx -y graph2agent-mcp@0.4.0Make a read-only graph2agent check . job required before a pull request can merge.
uses: graph2agent/github-action/.github/workflows/check-markdown.yml@48bc59a4742c2fd0311e81214b6571ce10601a4b
with:
graph2agent-version: v0.4.0Run daily, change only generated Markdown context, and reuse one focused refresh PR until it merges.
uses: graph2agent/github-action/.github/workflows/maintain-markdown.yml@48bc59a4742c2fd0311e81214b6571ce10601a4b
with:
graph2agent-version: v0.4.0Measured, with the caveats attached
The frozen paired result supports efficacy on this benchmark. It does not by itself prove broader model, task, or production generalization.
Mermaid alone
63.33%
209 / 330 exact
Mermaid + standard digest
81.82%
270 / 330 exact
Relative failure reduction
50.41%
121 failures reduced to 60; this is a relative error metric
Observed aggregate token counts. Mermaid + graph2agent relative to Mermaid-only across the same 330 paired cases.
8.17%more input tokens
14.13%fewer output tokens
46.30%fewer reasoning-output tokens
What this does not establish
standard digest were tested in this confirmatory result.Keep the diagram. Add the explanation.
Open graph2agentbrew install graph2agent/tap/graph2agentnpx -y graph2agent-mcp@0.4.0