An MIR Agent would need to handle Objects. So I built a system to handle Object storage.
I use an S3 compatible API in my backend and Garage as my locally hosted Object storage.
For uniqueness, I use content-addressable hashing. For each Object, I compute the SHA256 hash of the Object bytes and store it at that URI.
That way, if there happens to be the same Object in the Mirgenta system, it would only be stored once in Garage.
I address user access via separate metadata tables in the database. Two users who upload the same Object will both have access to that Object, but the upload into Garage only happens once.
Likewise, a tool call can also output Objects. These Objects are also stored in the Object Store. A realistic scenario in which a tool output and a user upload map to the same Object is when a user downloads a tool output and uploads it in a different session. So a single Object can also have multiple types (tool output, user upload).
When a user deletes a chat, I perform soft delete over the user-session-Object mapping. I currently don't have a mechanism for hard delete in Garage, but I could implement it. For now, I don't think it is necessary.
The content-addressable hashing combined with the tool and environment versioning system allow me to implement a rudimentary version of tool result caching. The idea is that in theory, if a tool consists of only deterministic functions (which many aren't), and we hash both the tool wrapper as well as the frozen environment dependencies, and the inputs are the exact same, we can reuse a previous tool output. This is why sometimes tools seem to run unusually fast. I don't try to simulate a small waiting time because I'm being transparent about what's going on behind the scenes.
I believe Tool Result Caching can be very sophisticated. If the server existed across different physical machines, the cache probably would not be defensible, since the computation won't be deterministic across different hardware. This is the same challenge behind reproducible builds: https://en.wikipedia.org/wiki/Reproducible_builds