Skip to content

feat: add agents workflow diagram to render an agent's workflow as a Mermaid flowchart - #177

Open
danieldutu wants to merge 1 commit into
elevenlabs:mainfrom
danieldutu:feat/workflow-mermaid-diagram
Open

danieldutu wants to merge 1 commit into
elevenlabs:mainfrom
danieldutu:feat/workflow-mermaid-diagram

Conversation

@danieldutu

Copy link
Copy Markdown

agents workflow diagram <config-path> prints the workflow of a local agent config as a Mermaid flowchart.

The config stores workflow.nodes and workflow.edges as raw JSON, which is hard to review in a diff. Mermaid renders natively on GitHub, so the output can be pasted into a mermaid code fence in a PR or doc. The command reads the file only: no API key, no network.

It reads the file as untyped JSON, so node types the CLI does not know yet still render.

Output rules:

  • Nodes and edges are sorted by id, so the output diffs cleanly.
  • Each node type (start, end, say, tool, update_state, override_agent, standalone_agent, phone_number) has its own classDef. The emitted class names carry a wf_ prefix (wf_start, wf_end, …): Mermaid treats end as a flowchart keyword, so a class named end is unsafe across Mermaid versions. Node ids get the same treatment through an n_ prefix.
  • A type the CLI does not know renders with the wf_other class.
  • An edge label is the forward condition's label, or its condition text, cut at 40 characters. Unconditional edges have no label.
  • A config without a workflow key exits with a validation error.

I edited cli/elevenlabs/workflow/diagram.rs and cli/elevenlabs/workflow/mod.rs by hand; both are in .fernignore, so regeneration leaves them alone. The README section is also hand-written.

Checks: cargo test diagram (3 passed), rustfmt --check on the touched file, and cargo clippy with no findings there.

Not in this PR: the GitHub Action, backward_condition arrows and an agent-name argument from the #170 proposal. I can add them in a follow-up. If you prefer another command name than agents workflow diagram, say so and I rename it.

Part of #170.

…Mermaid flowchart

Part of elevenlabs#170. The command reads a local agent config and prints the workflow as a Mermaid flowchart. It needs no API key and no network.

The emitted classDef names carry a wf_ prefix (wf_start, wf_end, ...). Mermaid treats end as a flowchart keyword, so a class named end is unsafe across versions. The type table keeps the plain node type names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant