Sessions

A session is the durable record of a run: an append-only entry log over a pluggable store. Kill the process, deploy, come back; the conversation continues from the same id. A tutoring agent that remembers where a student left off is one id away.

store = Mistri::Stores::JSONL.new("tmp/sessions")
session = Mistri::Session.new(store:)
agent = Mistri.agent("claude-opus-4-8", session:)
agent.run("Start today's lesson on Ruby blocks.")
# Next week, in another process: reload by id and pick up mid-course.
reloaded = Mistri::Session.new(store:, id: session.id)
Mistri.agent("claude-opus-4-8", session: reloaded)
.run("I'm ready for the next lesson.")

Stores

Three ship with the gem, and the interface is small enough to bring your own:

Mistri::Stores::Memory.new # in-process default
Mistri::Stores::JSONL.new("tmp/sessions") # one file per session
Mistri::Stores::ActiveRecord.new(AgentEntry) # your database

In Rails, generate the model first and name it whatever you like:

Terminal window
$ bin/rails generate mistri:install AgentEntry

Append-only on purpose

Entries are never rewritten. Approvals, denials, steers, and compaction summaries append to the log, which is what makes a run resumable from any process and your transcript views trustworthy.

Crashes heal

A deploy or crash that kills a run mid-tool leaves tool calls without results, a context every provider rejects. Replay heals it: unsettled calls answer with a synthesized interrupted result, calls parked for human approval stay open, and the stored log keeps exactly what happened.