A declaration. What bounds it is not the tool but the run: it can reach the storages passed as storages, and nothing else on the account.
Declaring it
const agent = api.agents.create({
model: { main: session },
storages: [database], // what this run may read
tools: { query_storage: api.tools.queryStorage },
maxSteps: 8,
});agent = api.agents.create(
model={"main": session},
storages=[database], # what this run may read
tools={"query_storage": api.tools.query_storage},
max_steps=8,
)The tool is declared and the run has nowhere to look. Listing the storages is the whole access decision — it happens in your code, once, before the run starts.
What the model sends
One parameter, request, as text: either the word collections, or a JSON object.
| request | On | Does |
|---|---|---|
"collections" | a document database | Lists the collections. |
{"collection":"leads","filter":{},"limit":10} | a document database | Reads documents. |
{"sql":"SELECT …"} | a relational database | Runs a statement. |
{"key":"invoices/2026.csv"} | a bucket | Reads one object. |
fields picks the columns and shortens long text. storage names which one, and it is needed as soon as the run holds more than a single storage.
{ "collection": "orders", "filter": { "status": "paid" },
"fields": ["id", "total", "createdAt"], "limit": 20, "storage": "Production" }{"collection": "orders", "filter": {"status": "paid"},
"fields": ["id", "total", "createdAt"], "limit": 20, "storage": "Production"}Why the request travels as text
Declared as an object, a filter comes back from the provider with its operators stripped — and a query with no operator is a different query, not a failed one. As a JSON string nothing is touched, so the filter the model wrote is the filter that runs.
Read only, and that is structural
There is no write in this tool. Changing a connected storage is a different declaration, with its own description and its own guards — so a run given this one cannot modify anything, whatever it is asked to do.
What the run gets back
The rows, the documents or the object, trimmed to what a turn can carry — a larger allowance than the other tools, because this one exists to bring data into the conversation. The step's summary says how much came.
There is a richer version
The local engine's own storage tool goes further: an overview in one call, a schema, counts, aggregation, semantic search, and a permission asked per storage. If your code can run the loop, prefer it.