mountable.io
By mountable.io · Community examples
  • smolagents
  • agents
  • filesystem

Give Your smolagents Tools a File the Next Process Can Read

A smolagents worker exits and the note it wrote goes with it. Two tools save that note on mountable.io so the next process can read the file.

Say you have built an agent with smolagents. One of its tools writes a note while the worker runs. The worker is a short job, and it exits when the task is done.

When the process exits, that note is gone. The next job starts from zero. You could add a database table to keep the file, and that is a lot to build for one Markdown note.

mountable.io is a persistent filesystem for AI agents. write_note stores the text on that user's filesystem. A later process calls read_note and gets the same file.

The next process opens the bytes that were stored. A person, the CLI, or a tool in another framework can open the same Markdown. For one note, that is less to build than a database table.

Diagram of two smolagents processes. Process A calls write_note, which stores notes/brief.md on the user's mountable.io filesystem, and then the process exits. Process B starts later, calls read_note, and reads the same file.
The process exits. The file stays on the user's filesystem.

Two tools, one file

Your app chooses the filesystem and the path before the tools exist. write_note takes the note text. read_note takes nothing. The first write stores the note and leaves an existing file in place.

from smolagents import tool
 
@tool
def write_note(text: str) -> str:
    """Create the note the application already chose.
 
    Args:
        text: The note as UTF-8 text, at most 16 KiB.
    """
    store.write(path, text, if_none_match=True)
    return "stored"
 
@tool
def read_note() -> str:
    """Read the note the application already chose."""
    return store.read(path).data.decode("utf-8")

Here store is the user's filesystem, opened by your backend with client.filesystem(user_filesystem_id), and path is a path such as notes/brief.md. Your backend chooses both. A model never sees the filesystem id or the API key.

Run it twice

The example has two commands. write calls write_note. read is a new process that calls read_note with a read-only handle.

uv run python notes.py write \
  --filesystem "$FS_ID" \
  --path notes/brief.md \
  --text "Parser review complete. Check the file next."
 
uv run python notes.py read \
  --filesystem "$FS_ID" \
  --path notes/brief.md

We ran both commands against production. The second process printed the same note. The example calls the tools through ToolCallingAgent.execute_tool_call and does not call a model, so you can try the handoff without a model key.

Try it

mountable.io maintains this example. It is not a Hugging Face package.