Agentic AI · L-Memory
Calculations and reasoning. The programming exercises (JSONL sessions, compaction) are in the
lab notebook lecture-Memory-lab.ipynb. Solutions in skip cells.
(a) Give two advantages of storing a growing conversation as JSONL — one JSON object per line — over one JSON array that holds every turn.
(b) A session log holds the following records, in the order in which they were appended:
{"id":"a1","parent_id":null,"role":"user","content":"Book a flight to Rome."}
{"id":"b2","parent_id":"a1","role":"assistant","content":"For which date?"}
{"id":"c3","parent_id":"b2","role":"user","content":"Friday."}
{"id":"d4","parent_id":"c3","role":"assistant","content":"Booked for Friday."}
{"id":"e5","parent_id":"b2","role":"user","content":"Saturday."}
{"id":"f6","parent_id":"e5","role":"assistant","content":"Booked for Saturday."}
c3 and d4 are not part of that conversation. Why are they still in the file, and
what does the agent gain from that?An agent has $n = 60$ skills. The metadata (name and description) of each skill takes $d = 80$ tokens, and each body takes $b = 3\,000$ tokens. In one session, $a = 2$ skills are activated.
An agent keeps a working memory $M_t$ and a session log on disk. For each operation below, state (1) whether it is a write $W$, a management step $P$ or a read $R$; (2) whether it calls a language model; (3) whether, after it, every record in $M_t$ is still verbatim text from the log or a marker, so that a removed record can be restored from the log.
| # | Operation |
|---|---|
| a | A tool returns 4 000 lines; the harness writes them to a file and stores the path and the first 20 lines as the step's record. |
| b | Only the last 30 records of $M_t$ are kept; all earlier ones are deleted. |
| c | The content of every tool result older than the last five is replaced by Old output omitted (101 lines). |
| d | A model call writes one text that replaces the records $m_1, \dots, m_\ell$. |
(e) A harness applies (a)–(c) first and (d) only if the context is still over budget. Explain the order with your answers to (3).
(a) Assign each item to working, semantic, episodic or procedural memory, and give a one-clause reason:
SKILL.md that describes how to write release notes.(b) The semantic store holds "Anna lives in Berlin" (written in March 2024). In November 2025 Anna says that she has moved to Hamburg. For each policy — replace at write time, append and resolve at read time, invalidate — state what the store holds afterwards. Which policies can still answer "Where did Anna live in 2024?", and what does each of them cost?
An agent with a memory stream (Park et al., 2023) is asked "Where does Anna live?". Three candidate records:
| Record | Text | Hours since last retrieval $h$ | Importance (1–10) | Cosine similarity to the query |
|---|---|---|---|---|
| $m_1$ | Anna lives in Berlin. | 2 000 | 6 | 0.82 |
| $m_2$ | Anna moved to Hamburg last month. | 20 | 8 | 0.71 |
| $m_3$ | Anna had coffee at the station. | 5 | 2 | 0.64 |
The score is $\text{recency} + \text{importance} + \text{relevance}$, all weights $\alpha = 1$, with recency $= 0.995^{h}$ and each of the three terms min–max normalised over the three candidates (smallest value $\mapsto 0$, largest $\mapsto 1$).
A coding agent works on a web application over several days, longer than one context window.
(a) For each design, state which party computes $W$, $P$ and $R$ — the harness, the model or a fresh agent — and name the failure that design is exposed to: (1) a compaction pipeline; (2) a model that writes and reads its memory through tool calls (as in MemGPT); (3) a context reset.
(b) In the harness of Young (2025), the handoff $\mathcal{H}$ of a context reset is a set of files. Name the four files, and explain why a new session runs one end-to-end test before it selects the next feature.
A personal assistant with a long-term store answers three questions wrongly:
(a) For each failure, name the operation — write, manage or read — at which it occurred. (b) An end-to-end benchmark scores only the final answer. Why can it not tell failures 1 and 2 apart, and what does a stage-wise benchmark such as HaluMem compare instead? (c) Why did the reset not remove failure 3, and at which operation does the check belong?
Peer-reviewed papers
Preprints & other non-peer-reviewed papers
Blogs, documentation & other web sources