Skip to content

fix(agent): render panel lost the connections on large SVGs - #99

Merged
elasticdotventures merged 1 commit into
mainfrom
fix/agent-svg-panel-truncation
Oct 15, 2026
Merged

elasticdotventures merged 1 commit into
mainfrom
fix/agent-svg-panel-truncation

Conversation

@elasticdotventures

Copy link
Copy Markdown
Member

Symptom: in the agent's Rendered diagram panel the boxes drew but the lines between them were missing; editing the code in the editor showed the correct diagram.

Cause: panel_from_tool_result ran the SVG through truncate(..., MAX_OUTPUT_CHARS=20000). D2 writes its connections after its shapes, so a 12-node diagram (24.5k chars, connections from ~18.7k) kept the boxes and about one line. The editor fetches the SVG directly, so it never hit the cap.

Fix: SVG panels get their own cap (KR0KI_STORYB00K_MAX_PANEL_SVG_CHARS, default 2,000,000). Model-facing text keeps the 20k limit.

Tests: two new cases in test_panels.py (a large SVG arrives whole; non-SVG text is still truncated). The first failed before the change. Agent suite: 85 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GgXQRGsprSZc2oXGNj9n8X

The agent cut every tool result at MAX_OUTPUT_CHARS (20k) before building the UI panel. That limit protects the model's
context, but it also cut the picture: D2 writes its connections after its shapes, so the panel drew boxes and lost the lines
while the editor (which fetches the SVG directly) was fine. SVG panels now get their own cap (2M chars,
KR0KI_STORYB00K_MAX_PANEL_SVG_CHARS); model-facing text keeps the 20k limit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GgXQRGsprSZc2oXGNj9n8X
@elasticdotventures
elasticdotventures merged commit be32c13 into main Oct 15, 2026
3 checks passed
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