Tools
seed_data.tools
Strands @tool wrappers used by agents in the graph.
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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
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
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 197 198 199 200 201 202 203 204 205 206 207 208 | |
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
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
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
26 27 28 29 30 31 32 33 34 35 36 37 38 | |
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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |