Skip to content

Agent persistence: record every tool call and assistant response, restore agent windows by replay #29

Description

@gregjkal

Summary

Agents must survive Workshop exit and relaunch. Every tool call and every assistant response is recorded to a per-agent SQLite database, and an agent window is restored by replaying that history into a fresh Lua VM. Serializing the Lua VM itself was researched on 2026-09-10 and rejected as infeasible.

Scenario

From the #cppa-wg21-org discussion on 2026-09-10:

  • An agent is a PromptForge prompt currently suspended at a tool call, typically tools.call("user_input"). Pressing Send resumes it and the tool returns the typed text.
  • The user exits the Workshop. Days or weeks pass. They relaunch, and the agent window must come back exactly where it stood.
  • The time evolution of a prompt is a linear sequence of suspensions at tool calls, so the record is a linear log.

Direction

  • Every agent owns an SQLite database that holds everything that ever transpired. "The agent is the database."
  • Restore replays every tool call and every assistant response from the history. No inference cost, no VM serialization.
  • When an agent is created, its agent script (e.g. chat.md) is copied into the database and pinned for the agent's lifetime. Editing the script on disk must not change existing agents.

Existing design to build on

  • design/design-promptforge-workshop.md, "The event store is the product; every interface is a view", and "Resume needs execution state, not just artifacts": append-only hash-chained log, simulated replay with recorded observations, the SQLite file an agent presents as a projection of the log.
  • guide/promptforge-agent-guide.md, "History across runs": a relaunched agent already sees its whole persisted history from its first instruction.

Open questions (Vinnie asked for these to be written down)

  • Global namespacing for tools.
  • What happens when a tool version is updated, or the tool catalog changes, on agent reload.
  • What happens when the PromptForge language undergoes an incompatible change on agent reload.
  • What happens to per-turn metadata a script added if the script that reads it back is different.

Vinnie proposed that people respond here with complete, architected plans so they can be compared.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions