SQL Tool
Warehouse truth beats hallucinated numbers. An open SQL prompt also drops tables.
A teller window into the vault — not handing over the master key.
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
Ask then query
Scroll inside the frame to explore · use + / − to zoom up to 200%
Model fills parameters. You run a template.
Key Takeaways
- 1.A SQL tool lets the agent query data you already trust. Prefer parameterized, read-only queries on a view.
- 2.Never concatenate model text into SQL. Cap rows and time; return a compact table, not 100k rows.
- 3.Templates or a schema-limited query builder. DB user is SELECT-only.
- 4.Bind parameters. Summarize wide results.
Learn elsewhere
- →Tool Validation
- →External APIs
Real Example
Scenario
lookup_order(id) runs SELECT … WHERE id = $1 LIMIT 1. The model never sees a string it can turn into OR 1=1.
What you would do
In Tool Calling & Function Calling, apply SQL Tool to this scenario: lookup_order(id) runs SELECT … WHERE id = $1 LIMIT 1. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Commands
Commands to Remember
Read-only roleBound parametersLIMIT + timeoutNo concat
Cheat Sheet
Quick recap
quick ref- •Teller window
- •Templates > free SQL
- •Cap rows
- •Writes need HITL
Common Mistakes
- ✕f"SELECT * FROM {table}"
- ✕Admin DB credentials on the agent
- ✕Returning 50k rows into the prompt
