Skip to content

fix(core): fix nested subgraph rendering for 3+ level nesting in draw_mermaid#35493

Open
Taehan (Hank) Kim (taehan79-kim) wants to merge 4 commits into
langchain-ai:masterfrom
taehan79-kim:taehan79-kim/fix-nested-subgraph-rendering
Open

fix(core): fix nested subgraph rendering for 3+ level nesting in draw_mermaid#35493
Taehan (Hank) Kim (taehan79-kim) wants to merge 4 commits into
langchain-ai:masterfrom
taehan79-kim:taehan79-kim/fix-nested-subgraph-rendering

Conversation

@taehan79-kim

@taehan79-kim Taehan (Hank) Kim (taehan79-kim) commented Mar 1, 2026

Copy link
Copy Markdown

Fixes #35492

The "empty subgraphs" section in draw_mermaid() skips multi-level prefixes (e.g., parent:child) due to the if ":" not in prefix check, causing 3+ level nested subgraph boxes to not render at all. This fix splits the prefix on : and opens subgraph blocks for each nesting level.

Before: if ":" not in prefix → skips multi-level prefixes entirely
After: prefix.split(":") → iterates each level, opens subgraph blocks per level

How did you verify your code works?

  • All 22 tests in test_graph.py pass (18 snapshots passed) (17 snapshots passed, no updates needed)
  • Added test_nested_empty_subgraph_mermaid regression test
  • make format and make lint pass
  • Manually verified correct rendering for 3-level, 4-level nesting with draw_mermaid_png()

Screenshots

Before (bug):
image

After (fix):
image

@github-actions github-actions Bot added fix For PRs that implement a fix core `langchain-core` package issues & PRs external and removed fix For PRs that implement a fix labels Mar 1, 2026
@codspeed-hq

codspeed-hq Bot commented Mar 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing taehan79-kim:taehan79-kim/fix-nested-subgraph-rendering (a888432) with master (1338871)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (a79298a) during the generation of this report, so 1338871 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions github-actions Bot added fix For PRs that implement a fix size: S 50-199 LOC and removed fix For PRs that implement a fix labels Mar 3, 2026
@taehan79-kim

Copy link
Copy Markdown
Author

Friendly ping Eugene Yurtsev (@eyurtsev), this has been open for ~3 weeks now. This was the first PR submitted for this issue, all tests pass, and it's a small, focused change. Happy to address any feedback if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs external fix For PRs that implement a fix size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested subgraph rendering fails for 3+ levels with draw_mermaid and xray=True

1 participant