Tools
seed_data.tools
Strands @tool wrappers used by agents in the graph.
calculator(expression)
Evaluate an arithmetic expression exactly — use it for every sum, product and total.
Supports numbers, + - * / // % ** (or ^), parentheses, and abs, round, min, max, sum, sqrt, floor, ceil; sum, min and max also take a list. Examples: "round(12.5 * 3 + 7.25, 2)", "sum([12.5, 7.25, 3])".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
str
|
The arithmetic expression to evaluate. |
required |
Source code in seed_data/tools.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
evaluate_arithmetic(expression)
Evaluate an arithmetic expression with no names, attributes or imports.
Source code in seed_data/tools.py
94 95 96 97 98 | |
make_ask_user_tool(on_question)
Build an ask_user tool that routes questions to a host callback.
This is our host-pluggable take on Strands' handoff_to_user (which is
stdio-only, as the Strands docs note): the agent calls ask_user when it
is genuinely uncertain, and the on_question(question) -> answer callback
decides how to collect the answer (terminal stdin, a notebook widget, a Slack
DM, a web modal). on_question is bound in the closure — like
make_render_tool — so concurrent agents never share question state.
The callback may return None (user declined / skipped) or raise; both are
turned into a benign "no answer — use your best judgment" tool result so a
dialogue hiccup never aborts inference.
Source code in seed_data/tools.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
make_render_tool(backend='xhtml2pdf')
Build a render_html_to_pdf tool with its backend bound in.
The backend is captured in the closure rather than read from a global env
var, so each doc-generator gets its own correctly-configured render tool and
concurrent workers with different renderers never collide. The tool keeps the
name render_html_to_pdf so the generator prompt can reference it.
Source code in seed_data/tools.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
preview_pdf(pdf_path)
Render a PDF to images so you can visually inspect the output.
Call this after generating a PDF to see what it actually looks like. Returns page images you can examine for layout issues, truncation, font sizing, whitespace, and rendering artifacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdf_path
|
str
|
Path to the PDF file to preview. |
required |
Source code in seed_data/tools.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
random_roll(percent_chance)
Roll a random decision with a given percent chance of returning true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
percent_chance
|
int
|
Integer from 1-100 representing the probability of returning true. e.g. 70 means 70% chance of true, 50 means 50% chance of true. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
{"result": true} or {"result": false} |
Call this once per decision independently — never reuse the same result for multiple decisions.
Source code in seed_data/tools.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
read_json_file(file_path)
Read a JSON file and return its contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the JSON file to read. |
required |
Source code in seed_data/tools.py
122 123 124 125 126 127 128 129 130 131 132 133 134 | |
save_json_file(file_path, json_content)
Save JSON content to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path where the JSON file should be saved. |
required |
json_content
|
dict
|
The JSON object to save. A JSON-encoded string is also accepted and will be parsed before saving. |
required |
Source code in seed_data/tools.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |