Chapter V · Knowledge management

Session JSONL as Memory Source, Not Noise

Transcript logs are an audit trail and a mining seam. Treat them as search-only source material, not something to shovel raw into every prompt.

What this is

OpenClaw stores session history on disk as JSONL files under ~/.openclaw/agents/<agentId>/sessions/*.jsonl. That is useful. It means you can answer “what was said when,” recover the real shape of a past session, and feed a memory sweep from ground truth instead of vibes.

It is also dangerous if you use it lazily. Raw transcripts are noisy, repetitive, and full of ephemeral junk. If you load whole session logs into context or dump them into memory cards unchanged, you turn your memory system into a landfill.

This guide is the sane middle path: transcripts stay searchable, quotable, and auditable. Durable memory stays curated.

Why this way

You have three choices:

ModelFeels convenientFailure mode
Ignore transcripts completelyLess storage to think aboutYou lose the best source for “what actually happened?”
Load raw transcripts into prompts or notesMaximum context, supposedlyToken burn explodes. Important facts drown in tool chatter.
Search transcripts, then promote only durable factsSlightly more workThis is the one that scales.

Conversation history and memory are different jobs.

Mix those up and the system gets dumber as it gets bigger.

Prerequisites

Before / After

Before: every question about prior work becomes either guesswork or a full transcript reread. Memory cards start copying giant conversation chunks. Searches surface tool spam and status chatter instead of actual decisions.

After:

Implementation

1. Treat transcript logs as source material

The JSONL store is not your memory layer. It is the raw evidence layer.

Typical uses:

Not typical uses:

2. Search first, extract second

The right workflow looks like this:

  1. Search transcripts for the topic or phrase
  2. Pull only the relevant span
  3. Decide whether the span contains durable knowledge
  4. Promote the distilled fact, not the whole transcript

That can be powered by semantic search, plain grep, or a hybrid index. The method matters less than the discipline.

3. Know what is worth promoting

Good candidates for promotion out of transcripts:

Bad candidates:

If the best version of the memory still looks like a chat log, it probably should not be memory.

4. Keep role boundaries straight

Transcript lines are not all equal.

Example:

5. Use transcripts to drive memory sweep jobs

This is where JSONL gets genuinely useful.

A sweep job can review recent sessions and extract:

That is much better than relying on memory cards alone, because cards only show what already got promoted. Transcript logs show what got missed.

6. Keep the trust boundary tight

Transcript logs often contain:

Lock down the session-log directory. If you need stronger separation between agents or users, separate them at the OS-user or host boundary, not just in prompt instructions.

7. Retention is part of the design

Decide upfront what stays forever and what rolls off.

If you retain transcripts forever, index them in a way that favors recency. Otherwise search quality quietly gets worse as the archive grows.

Verification

Basic inspection on a host running OpenClaw:

# 1. Count transcript files by agent
find ~/.openclaw/agents -path '*/sessions/*.jsonl' | sed 's#.*/agents/##; s#/sessions/.*##' | sort | uniq -c

# 2. Inspect the shape of one recent transcript line-by-line
LATEST=$(find ~/.openclaw/agents -path '*/sessions/*.jsonl' | sort | tail -1)
echo "$LATEST"
head -5 "$LATEST" | jq .

# 3. Search transcripts for a phrase or decision
grep -Rni 'memory sweep' ~/.openclaw/agents/*/sessions/*.jsonl | head

# 4. Estimate recent transcript volume
find ~/.openclaw/agents -path '*/sessions/*.jsonl' -mtime -7 -printf '%s\n' | awk '{sum+=$1} END {print sum " bytes in last 7 days"}'

Healthy signs:

Gotchas

Whole-transcript loading is token arson. It feels safe because you think “more context means better answers.” Usually it means the model spends half its attention on stale tool chatter and buried status noise.

Tool messages dominate raw logs. The most verbose thing in a session is rarely the most important thing. If your transcript mining pipeline does not explicitly down-rank tool spam, it will surface the wrong stuff.

Assistant claims are not always facts. A transcript is the record of what was said, not proof that the claim is still true. If the assistant said a file lived at a path three weeks ago, re-check the file today before promoting it.

Privacy failures compound. Session logs often contain more than people realize. A copied stack trace might include hostnames. A tool result might include tokens or private links. Keep transcript access narrow and audit it like you would any other sensitive datastore.

Recency matters. Old transcripts are useful, but they should not outrank yesterday’s correction or this week’s design change. Indexing without age-awareness turns archaeology into the default answer path.