Point at a Python file, get back a structured health report. TheDocumentation Index
Fetch the complete documentation index at: https://docs.sirenspec.dev/llms.txt
Use this file to discover all available pages before exploring further.
python tool node calls a local analyze.py module that uses the standard library ast module to measure line counts, function lengths, and argument complexity — no external dependencies. An LLM then interprets the raw numbers and writes concrete improvement suggestions.
What it demonstrates
pythontool node calling a local module function- Chaining a tool node to a downstream agent via an edge
- Using
{{ analyze.metrics }}to pass tool output into an agent system prompt - Reading from
CODE_HEALTH_FILEenv var for flexible file targeting PYTHONPATHfor importing a recipe-local Python module
Prerequisites
Theanalyze module lives alongside the workflow. Set PYTHONPATH so the runtime can find it:
sample.py:
Run it
Workflow
docs/cookbook/code-health-report/workflow.yaml
Python tool node
args are not template-interpolated — they are passed as-is to the function. The run_analysis function reads CODE_HEALTH_FILE directly from os.environ, which is why no args are needed here.How data flows
analyzecallsanalyze.run_analysis()from the local module. The function reads a Python source file, parses it withast, and returns a metrics dict (line counts, function count, average function length, max argument count).- The result is written to
working.analyze.metrics. interpretresolves{{ analyze.metrics }}in its system prompt and generates the health report.
Graph
Next steps
Tool Nodes
Full HTTP and Python tool node reference, including module resolution and error handling.
Blind Code Review
Multi-turn refinement: write code, review it, then revise — without the reviewer seeing the spec.