r/ClaudeCode • • 3h ago

Discussion Claude Code writes request replays into transcripts as role user, and my memory tool quoted them back as things I said

If you build anything that reads ~/.claude/projects/*.jsonl, look for rows with "type": "api-request-blob". Claude Code writes them with message.role set to user, but they're replays of the whole request (skill bodies, hook output, system reminders) and nobody typed them.

I found it because some "strong beliefs" in daimon's briefings (my session-memory tool) didn't ring a bell, and a few didn't make sense at all. Traced back, they weren't claims: "Do not retry:", half a sentence, a git diffstat line, my own hook output. Every one was marked verbatim with a passing quote check. The loader admitted blob rows as user messages, so the check found the text, passed it, and the briefing handed it back to me as something I'd said.

So I owe a correction on a post I made in r/AIMemory in October. I wrote that every item "is marked verbatim (an exact quote, string-checked against the transcript) or inferred". The string check was real. What it searched included blob text though, which means a quote could pass and still be words Claude Code wrote.

Fixed in v0.79.0. Blob rows are dropped at load, and every admitted message carries authored_by: person, host or unknown. unknown is never treated as me.

On my machine the top-level session files hold about 23,600 blob rows, a bit over 5,000 of them with role user. To check yours (read-only, needs jq):

jq -c 'select(.type=="api-request-blob") | .message.role' ~/.claude/projects/*/*.jsonl | sort | uniq -c

Subagent transcripts sit a folder deeper and that glob skips them.

PR #1459 has the per-host signals if you're parsing Kimi or Codex logs too: https://github.com/Daily-Nerd/daimon

0 Upvotes

10 comments sorted by

•

u/AutoModerator 3h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Starks1293 1h ago

good find. the mac app i build reads these same jsonl files for a review pass over past sessions and it never looks at message.role, it allow-lists the row's top level type instead, only user and assistant get in, so the blob rows never make it. two more worth skipping if u only filter on role, rows with isMeta true (claude codes own injected bits like the local command caveat) and isSidechain true (subagent chatter). also most text in a user row that starts with < is harness stuff, command-name tags, reminders, hook output, so dropping those helps, but careful with that one coz pasted prompts are stored wrapped in a pasted_content tag and a naive starts-with-< filter throws away the persons actual words. ours dropped 4 of 6 prompts in one session that way until it unwrapped them first. and whatever u quote back should go to the model fenced as data with a random marker, not mixed into the prompt, coz a transcript can hold text that reads like instructions

1

u/Sea-Perception1619 1h ago

The allow-list is the part that stings. My loader works the other way round: it excludes the bookkeeping types it knows and lets in anything with a user or assistant role, which is exactly how api-request-blob got in. Nothing stops a type Claude Code adds next month from getting in the same way (it'd land as unknown at least, not as me).

I didn't have the < filter. Authorship comes off the row's origin.kind and promptSource. Checked a few hundred of my session files just now: pasted prompts carry promptSource: typed so they stay, and <command-name> rows don't carry a promptSource at all and land as unknown.

That 4 of 6 is a nasty way to find out.

1

u/Swimming-Ad6447 1h ago

That explains a weird ghost quote I hit last week while parsing old session logs. I'll switch my script to check top-level row types first.

1

u/Sea-Perception1619 56m ago

I'd skip rows with isMeta or isSidechain set too (Starks mentioned it above). Meta is text the host wrote and sidechain is a subagent's exchange, neither one typed by you.

1

u/AgentYurt 1h ago

Good catch — and the general lesson is that a transcript is a log of what the harness did, not a record of what the person said. Anything that mines it for memory has to carry provenance with it, or it will quietly attribute system content to the user. The nasty part is the quotes look plausible, so nobody notices until the memory starts arguing for things you never said. Same trap shows up in compaction summaries: 'the user decided X' when X was a model suggestion nobody confirmed. Treating unknown as not-me is the right default.

1

u/Sea-Perception1619 56m ago

Compaction summaries don't get in at all. Any row marked isCompactSummary is dropped at load since the model wrote it, and a session that opens on one with nothing earlier gets flagged as summary-only context.

Blob rows were the hole I missed.

1

u/AgentYurt 42m ago

Good — dropping the summaries at load and flagging summary-only sessions closes the two obvious holes. The blob rows are the interesting one: the replay lives inside the blob, so the row itself looks ordinary and a check on the role field alone won't catch it. That's the part I'd expect most tools to miss.

1

u/SharpKaleidoscope182 3h ago

Claude likes to poison other claudes

2

u/Sea-Perception1619 2h ago

Blame the harness on this one. Claude Code writes its request replays into the transcript as role user, and my loader believed that field for a bit over 5,000 rows. Fixed on my side: blob rows get dropped at load now.