Storage in Practice: A Friendly Guide
Room storage is a shared, durable file store scoped to a room. Think of it as a simple, reliable “shared drive” that agents and clients can read from and write to while they collaborate.When to use storage
- Persist files that are too big or too binary for Sync (audio, images, PDFs, logs, model outputs).
- Share artifacts between agents (reports, intermediate results, exports).
- Provide downloadable files to users (use
download_urlfor a direct link).
When to use something else
- Use Sync for live, collaborative documents or structured content that needs real-time merging.
- Use Database for queryable, structured records that you will filter, aggregate, or index.
How it works (mental model)
- Open a file and write to a handle in chunks.
- Close the handle to finalize the write and emit
file.updated. - Read with
download(small files) ordownload_url(large files). - List or delete entries when you are done.
exists or stat before open.
A simple workflow
TypeScript
Permissions and safety
Storage access is controlled by a storage grant on the participant token. Grants are path-based, so you can allow reads underoutputs/ while keeping inputs/ read-only, for example. Use clear path prefixes (inputs/, outputs/, artifacts/) to keep access rules and cleanup policies simple.