Skip to main content
Attach and read session media through AgentOS, then request object cleanup when deleting the session.
Session deletion and object cleanup are not atomic. AgentOS records the storage keys, deletes the session rows, then attempts a best-effort object sweep. A storage failure still returns a successful deletion and can leave orphaned objects.
media_storage_delete.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export environment variables

4

Configure AWS credentials

Configure the AWS SDK default credential chain with environment variables, a shared credentials file, or an IAM role.
5

Run the example

Save the code above as media_storage_delete.py, then run:
6

Attach and read a file

In another terminal with curl and jq, attach a repository file, resolve its storage key from the session, and read it through AgentOS:
7

Delete the session and request cleanup

Delete the rows and request the best-effort storage sweep. Verify the object separately in S3 when cleanup assurance matters:
Full source: cookbook/05_agent_os/02_databases/media_storage_delete.py