Skip to content

Interview question · Agent Memory & State

Where does an agent keep its notes during a task that takes eight hours?

Not in the context window, and not in long-term memory. In durable run state outside the process, structured, written atomically, and enough on its own for a fresh context to pick up the work.

mediumNewUpdated Nov 2026

TL;DR: In durable run state that lives outside both the model's context and the agent process: a structured notes file in the workspace or a record in a run store, written atomically after each meaningful step. It holds the goal and constraints (owned by the harness), a task list with status, decisions with reasons, what failed, and current handles. It survives compaction, a crash and a deliberate fresh start, because the test of good notes is that a new context with only the notes and the workspace can carry on. It belongs to the run; long-term memory receives only what is worth keeping afterwards.

How to approach it

List what can interrupt an eight-hour run: context limits, compaction, a process crash, a deploy, a pause for approval. Then pick a home for the notes that survives all of them, and define what goes in.

A strong answer

Not the context window. Anything only in the transcript is lost to compaction or a restart, and over eight hours the transcript will be compacted several times.

Not long-term memory. Notes are working state for this run: half-finished plans, guesses being tested, today's file paths. Writing them into cross-run memory pollutes it with transient detail.

Durable run state, outside the process. For a coding agent, a notes file in the repository's working tree plus commits as checkpoints is the natural home; for other agents, a record in the run store keyed by run id. Either way:

## Goal (fixed)        Migrate 212 report endpoints to the v2 API
## Constraints (fixed) No change to response shapes. Keep v1 live until sign-off.
## Tasks               done 137 · in progress 1 (reports/export) · todo 74 · blocked 0
## Decisions           Cursor pagination, not offsets (offsets broke on 50k-row reports)
## Failed              Bulk codemod broke 9 custom-serializer endpoints; doing by hand
## Handles             branch migrate-v2 · last green 8c41e2a · tests: make test-reports
## Next                finish reports/export, then the 9 custom-serializer endpoints

Written atomically. A crash halfway through a write must not leave half a notes file:

import json, os, tempfile

def save_notes(path, notes):
    folder = os.path.dirname(path) or "."
    fd, tmp = tempfile.mkstemp(dir=folder, suffix=".tmp")
    with os.fdopen(fd, "w") as f:
        json.dump(notes, f, indent=1)
        f.flush(); os.fsync(f.fileno())
    os.replace(tmp, path)          # atomic on the same filesystem

def resume(path):
    with open(path) as f:
        n = json.load(f)
    todo = [t for t, s in n["tasks"].items() if s != "done"]
    return f"goal: {n['goal']} | next: {todo[0]} | left: {len(todo)}"

d = tempfile.mkdtemp()
p = os.path.join(d, "notes.json")
save_notes(p, {"goal": "migrate reports to v2",
               "tasks": {"reports/list": "done", "reports/export": "doing",
                         "reports/share": "todo"}})
print(resume(p))  # => goal: migrate reports to v2 | next: reports/export | left: 2

The test of good notes. Start a fresh context with only the system prompt, the notes and the workspace, and see whether the agent continues correctly. If it re-does finished work or retries the failed codemod, the notes are missing something. Many long-running harnesses deliberately start fresh contexts at intervals and rely on this, instead of compacting forever.

Ownership. The harness owns the fixed sections and the task list's structure; the agent updates status, decisions, failures and handles through a tool, so a wandering turn cannot rewrite the goal.

After the run. A consolidation step may propose lasting lessons ("cursor pagination needed for large reports") to long-term memory under the usual write policy. The notes themselves are archived with the run.

What interviewers probe next

"Why a structured file and not free text?" Fields like task status and handles are read by code (to resume, to report progress) and must not drift. Free text is fine for decisions and failures.

"Two agents work on the same eight-hour task in parallel." Each needs its own notes for its branch of work, plus a shared task list with claims, written with the same atomic and conflict-aware rules.

"How often should it write?" After every meaningful step: a task finished, a decision made, an approach abandoned. Losing ten minutes on a crash is acceptable; losing two hours is not.

How it's scored

Weak: Keeps notes in the conversation, or writes everything to long-term memory.

Hire: Durable, structured run state outside the context that survives compaction and restarts.

Strong Hire: Durable state outside the process, written atomically, with harness-owned fixed sections, a task list, decisions, failures and handles; validates it with a fresh-context resume test; and separates run notes from long-term memory with a consolidation step.

Common mistakes

  • Notes that live only in the transcript.
  • Non-atomic writes that corrupt the file on a crash.
  • No record of failed approaches, so they are retried after every restart.
  • Promoting transient run detail into long-term memory.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.