Drug-Safety Agent on Databricks · Tools
The three tools
The model can call three tools and nothing else. All three are read-only. None takes free text that could be used as a database query: each takes a drug name and an event name. That makes the question "what could the agent do wrong with its tools?" easy to answer: it can look things up.
| Tool | Takes | Returns | Where the arithmetic is |
|---|---|---|---|
| get_report_counts | drug, event | a, b, c, d and the fetch date | none: it is a lookup |
| get_signal_stats | drug, event | cases, PRR, ROR and its 95% interval, whether it screens as a signal | code, never the model |
| get_label_mentions | drug, event | on the label or not, boxed warning or not, short quotes with the section | none: text search with listed synonyms |
A note on names. The specification calls the tools get_report_counts, get_signal_stats and get_label_mentions, and the tool facade presents those names. The local Python versions have shorter names (report_counts and so on), as the registry below shows.
Why not let the model write SQL? A model that writes its own queries can read what it should not and can be tricked by text in the data into running something unintended. Three fixed tools remove that whole class of risk.
The real code
Cut from the repository each time this site is built, so it always matches what runs. Each header names the file and the line it was cut from.
src/drugsafety/tools.py:121The registry: the model sees these three names and nothing elseTOOLS = {"report_counts": report_counts, "signal_stats": signal_stats, "label_mentions": label_mentions}