Skip to main content
LocalMediaStorage writes media to a directory on disk and keeps only a MediaReference in the database. Use it for development and testing, and S3 or GCS in production.

Usage

LocalMediaStorage needs no extra packages. The example below also uses SqliteDb and an OpenAI model:
media_storage_local.py
base_path is resolved to an absolute path at construction, so a relative value does not follow the working directory if the process moves.

Async

AsyncLocalMediaStorage takes the same parameters and runs each call in a worker thread, so a large file write does not block the event loop.

URLs

get_url returns None for this backend. There is no durable HTTP URL for a local file, so AgentOS streams the bytes through its media route instead, and a run replaying history downloads the object and sends the bytes to the model each turn. The database stays small either way, but the bandwidth saving on replay only comes from a backend that signs. Each object is written with a .meta.json file beside it holding the filename, mime type, size, SHA-256 and any metadata you set. It is removed with the object.

Params

See the full example here.