DEV Community

Shashank Shekhar
Shashank Shekhar

Posted on Fully Autonomous

Where should your agent keep its work between sessions?

My agents kept losing their work. A session would build a tracker, a ledger or a report. The next session could not find it. Sometimes it found an old copy and wrote over a newer one.

The model was not the problem. The problem was where the work lived. A chat transcript ends with the session. A folder of markdown files has no versions, no checks and no idea who else is editing it.

So I gave my agents a system of record. It is a remote MCP server, and the agent keeps its work there in workbooks.

What is a workbook?

A workbook is a set of tabs. Each tab is markdown: a table, or a page of notes. A workbook can also be an Excel or Word file, or a sheet linked to Google Drive or Dropbox. In that case the file in the drive stays the record.

Four rules make it safe for an agent to use.

1. Every write is a new version. The agent never edits in place. Each write makes version N+1 and keeps version N. Any earlier version can be read or restored.

2. A stale write is refused. The agent says which version it based its write on. If someone else wrote a newer version since, the write fails. Nothing is merged over. The agent reads the new version and tries again.

3. Edits are checked like code. A workbook can carry a schema. It declares each table's columns, types, required cells, keys and references. Every write is compiled against it. A bad cell comes back as an error, the way a compiler answers. The agent fixes the cell and writes again.

4. Everyone reads the same thing. Claude, ChatGPT, Codex and Cursor connect to the same server. So does a person in the web app. A workbook one agent writes on Monday is the one another agent reads on Tuesday.

A real example

This week I asked Claude Code to plan an outreach pilot. I wanted the plan to be checkable, not just plausible.

It kept four tabs in one workbook:

  • Model. A TLA+ specification of the rules: who may be contacted, how often, and when the pilot may scale.
  • TLC result. The model checker's output. Nine safety rules hold across about 41,000 states. One rule was written to break on purpose, and its trace is the shortest path to a decision to scale.
  • Simulator. A Monte Carlo simulation of the funnel, with the priors written down so they can be replaced after the pilot.
  • Ledger. Who was contacted, how each address was checked and when each message goes out.

The workbook went through four versions in one afternoon. Each has a one-line summary of what changed. When I wanted to know why the ledger had grown from 14 rows to 50, I read the version history. I did not have to scroll back through a chat.

How the agent uses it

The server exposes a small set of tools. The ones an agent uses most are:

  • find_workbooks: look for the workbook that already exists before making a new one.
  • read_workbook: read the current version, or any earlier one by number.
  • write_workbook: write a new version, based on the version it read.
  • checkout_workbook: copy the tabs into a shell, edit them with scripts, then commit them as one version.

The last one matters for big edits. The agent can use sed, awk or Python on plain files and commit once. The schema check still runs on commit.

The server also has live data programs the agent can run from the same shell. These include Google Trends, SEC Form D filings and US customs records. Their results can go straight into a workbook.

Install

Claude Code:

claude mcp add --transport http --scope user hedwigai https://mcp.hedwigai.com
Enter fullscreen mode Exit fullscreen mode

Then run /mcp, pick hedwigai and authenticate in the browser. Sign-in is OAuth 2.1 with dynamic client registration, so there is no token to paste.

Codex:

codex mcp add hedwigai --url https://mcp.hedwigai.com && codex mcp login hedwigai
Enter fullscreen mode Exit fullscreen mode

Claude, ChatGPT and Cursor: add https://mcp.hedwigai.com as a custom connector.

The server is in the official MCP registry as com.hedwigai/hedwigai.

Try it with your own server

If you build MCP servers, I will turn on two weeks of free inference for your account. Sign up and leave a comment, and I will set it up. After the two weeks, three open models stay free to use as much as you like.

For a wider view, I compared 24 places agents can save their work, from Tencent's Agent Bucket and Google's ADK artifacts to AWS AgentCore, Claude and OpenAI: where do AI agents save their work?

How does your agent keep its state across sessions today? I would like to hear what works and what breaks.

Disclosure: I build hedwigai.

Top comments (0)