Persistent Files for the OpenAI Agents SDK, One Filesystem per User
A user asks your agent to save a note. They return the next day, and a fresh run starts without the file. In an app serving many users, keeping the note also means knowing whose it is.
mountable.io is a persistent filesystem for AI agents. Our Python example provides file tools for the OpenAI Agents SDK. Your backend gives each user their own filesystem and reuses it on later requests.
Your backend chooses whose files to open
A filesystem ID supplied by a model could steer a tool into another user's files. Instead, your backend looks up the filesystem for the signed-in user. It passes that handle to the agent as local context.
The note path comes from your backend too. The model gets two tools: create a note and read it. The core pattern looks like this:
@function_tool(failure_error_function=None)
async def write_note(ctx: RunContextWrapper[Workspace], text: str) -> str:
await asyncio.to_thread(
ctx.context.filesystem.write, ctx.context.note,
text, if_none_match=True,
)
return "Note created."
@function_tool(failure_error_function=None)
async def read_note(ctx: RunContextWrapper[Workspace]) -> str:
note = await asyncio.to_thread(ctx.context.filesystem.read, ctx.context.note)
return note.data.decode("utf-8")A fresh context can read the same note on the next request. The create-only write protects a note that is already saved. The complete example adds size checks and handles that existing-note response.
We exercised these tools through the Agents SDK's tool interface against production mountable.io storage. Separate filesystems kept separate notes, and fresh clients read them back. The check also confirmed that another create left the original note intact.
Set a cap for each user's filesystem
Your backend sets a monthly spending cap when it creates the user's filesystem. At that cap, the user's billable work stops with a 402 response. Other users keep working on their own filesystems.
The example lets that error end the run. Only your backend can change the cap. OpenAI model usage is billed separately from mountable.io storage and operations.
Follow the setup guide to provision a capped filesystem, save its ID for the user and connect the tools. The runnable example is maintained by mountable.io, independently of OpenAI.