← Applied AI
Applied AI· 1 min read

Agent Memory and Durable Execution

.NETAI EngineeringIndian Case Law

Summary

Save the research checkpoint separately from any chat transcript, then delete it.

Companion code: 10-memory in indian-legal-ai-lab.

Previous: Part 9: Event-Driven Judgment Ingestion

A research session should survive a restart. The file that survives should be the verified passages and the stage, not a chat transcript.

What is stored

`SessionStore` takes a directory and creates it. `PathFor` joins that directory with `{sessionId}.json`. `SaveAsync` serializes the whole `ResearchState`: question, passages, analyses, verification notes, report, and stage. There is no message list on that type, so a model transcript cannot be written by this store.

`LoadAsync` returns null when the file is missing. `Delete` removes the file if it exists. The API maps `DELETE /sessions/{id}` to that method. The Blazor history page loads the same file from the `session` query string.

Resume uses the stage gates from Part 8. A state saved at `analyze` skips discovery. `Session_can_resume_and_be_deleted` saves that stage, calls `RunAsync` with the loaded state and a Thappar question, expects `completed`, then deletes the file and expects a null load.

dotnet run --project labs/10-memory

The lab saves stage `verify` under the temp directory `lab10-sessions`, prints `verify`, deletes the file, and prints `True` when the reload is null.

The files are plain JSON. Do not point the store at a directory of client matters. This sample uses public judgments and fictional fixtures.

Atomic write

`SaveAsync` writes `sessionId.json.tmp` and then moves it over the destination. A session id that is not letters and digits throws. `Session_id_rejects_path_traversal` uses `../etc`.

Next

Part 11: Evaluation, Security, and Reliability

Verified in this revision

`SessionStore.SaveAsync` writes a temp file and moves it. `PathFor` rejects a session id that is not letters and digits. A session is the `ResearchState` JSON, not a chat transcript.

More in Applied AI