Repository navigation
fix(ai): Draw diagrams from structured data - #381
Merged
Merged
Conversation
…ted code The DFD and architecture diagram tools take the diagram as structured data, validate it, and draw it with one shared renderer. The examples tool and the code scanner are removed. - Generate each tool's input schema from its pydantic model, with refs inlined. - Give DFD flows a required, unique id (DF1, DF2, ...) drawn as "DF1: label". - Answer list_icons queries from the icon index only. - Suggest close icon names when an icon is unknown. - Keep bandit as a dev dependency and bound pydantic below 3.
strands-agents-tools 0.9.0 removed strands_tools.file_read, which the file read tool wraps. uv tool install and uvx ignore uv.lock and picked 0.9.0, so the CLI failed on import. The lock already pins 0.8.6; no versions change.
dboyd13
self-requested a review
November 11, 2026 07:02
|
🎉 This PR is included in version 1.0.92 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
N/A
Reason for this change
The diagram agents wrote Python for the
diagramslibrary, and the tools ran it to draw the SVG. A small slip in that code, such as a wrong import or a bad constructor argument, failed the whole step, and errors came back as Python tracebacks. Structured input fixes this: the model fills in a fixed shape, and the tool draws it the same way every time.This affects CLI and MCP server users only. The web app and the extensions don't change. The MCP server doesn't expose the diagram tools directly; they run inside the workflow.
Description of changes
threat_composer_dia_dfdtrust_boundaries,elementsandflowsinstead ofcode. Each flow has a requiredidmatchingDF1…DF9999, unique within the diagram, and is drawn asDF1: <label>. The threats agent relies on these ids.threat_composer_dia_architectureclusters,nodesandedgesinstead ofcode. Icons are names likeaws.compute.EC2, checked against the icons thediagramspackage ships. A bare class name such asEC2works when it is unique. A node without an icon is drawn as a plain box. Edges take an optionalstyle(solid, dashed, dotted, bold).threat_composer_dia_common.py. Labels are drawn as plain text.inputSchemais generated from its pydantic model, with$refs inlined, so the schema the AI model sees always matches what the tool accepts. Field help comes fromField(description=...).aws.compute.Lambdaforaws.compute.Lamda.threat_composer_dia_list_iconsidand the description inlabel. The examples tool, which returned Python snippets, is removed.banditmoves from runtime to dev dependencies: only the removed code scanner used it at runtime.pydantic>=2,<3is now declared directly, since the tools import it.strands-agents-toolsis bounded to>=0.2,<0.9: 0.9.0 removedstrands_tools.file_read, which the file read tool wraps, anduv tool installanduvxignoreuv.lock, so an install from git picked 0.9.0 and the CLI failed on import.uv.lockalready pinned 0.8.6. It adds onlybanditandstevedore; no existing versions change.Describe any new or updated permissions being added
None.
Description of how you validated changes
tests/tools/test_diagram_tools.pycovers input validation, DF ids, generated schemas, icon names and suggestions, label rendering, rendering from a worker thread,list_iconsmaking no file system calls on its input (test_ai_file_access_list_icons_ignores_paths), and a check that the package makes noexec/eval/compile/__import__calls.tests/test_dependency_bounds.pychecks that thestrands-agents-toolsbound allows 0.8.6 and excludes 0.9.0. It fails with the old<1bound.pnpm nx run threat-composer-ai:build(install, ruff check and format, tests) exits 0: 242 passed, 6 skipped. The 6 skips are intests/eval/test_fixture.py. Graphviz was installed locally, so the render tests ran; CI doesn't install Graphviz, so they skip there.pnpm lint, which.husky/pre-commitruns, exits 0.global.anthropic.claude-sonnet-5,eval/browser-extension.json): PASSChecklist
type(scope): Subject. It becomes the commit message onmain.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.