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.
```mermaid
flowchart TD
Request --> auth{Authorized?}
auth -->|yes| API
auth -->|no| Reject
```Agent explanation · hidden in rendered Markdown
<!-- graph2agent:begin …
Branch candidate: `Authorized?`.
`Authorized?` points to `API`, labeled “yes”.
`Authorized?` points to `Reject`, labeled “no”.
Terminal nodes: `API` and `Reject`.
Shape does not prove runtime decision semantics.
graph2agent:end -->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.
flowchart TD
request[Request] --> auth{Authorized?}
auth -->|yes| api(API)
auth -->|no| reject[Reject]Agent must reconstruct:
Elements
- `Request` is a rectangle.
- `Authorized?` is a decision-shaped element.
Explicit relationships
- `Request` points to `Authorized?`.
- `Authorized?` points to `API`, labeled “yes”.
- `Authorized?` points to `Reject`, labeled “no”.
Derived topology
- Branch candidate: `Authorized?`.
- Terminal nodes: `API` and `Reject`.
Interpretation limits
- Shape does not prove runtime decision 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
Read the evidence boundaryOne compiler, four launch surfaces
Core v0.2.1, Action v0.3.0, Homebrew, and direct Debian downloads are public. MCP v0.2.0 is prepared for npm publication; 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 generateThe prepared npm umbrella package gives an MCP-capable agent the tool without a manual native download. This command becomes live when v0.2.0 is published to npm.
npx -y graph2agent-mcp@0.2.0Make a read-only graph2agent check . job required before a pull request can merge.
uses: graph2agent/github-action/.github/workflows/check-markdown.yml@7c57998614ba579be55829423eaaa1262c35eff4
with:
graph2agent-version: v0.2.1Run daily, change only generated Markdown context, and reuse one focused refresh PR until it merges.
uses: graph2agent/github-action/.github/workflows/maintain-markdown.yml@7c57998614ba579be55829423eaaa1262c35eff4
with:
graph2agent-version: v0.2.1Measured, 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.