Repository navigation
Description
Problem
The session parser treats anything with a user role as something the human typed. In practice the native transcripts carry injected context, compaction summaries and internal markers in the same role, so "user messages", question counts and the derived scoring include text the person never wrote.
Read-only measurement on one machine (teamai-cli 0.30.0; scripts not included):
- Claude Code (
~/.claude/projects/*/*.jsonl): besides entries withisMetaandisCompactSummary, there are records starting with<system-reminder>,<task-notification>, an interruption marker or a slash-command marker that carry noisMetaflag — 340 + 15 of them in a 93 MB transcript. - Codex (
~/.codex/sessions/**/*.jsonl): in the 5 most recent files there is noevent_msgof typeuser_messageat all; typed input appears asevent_msg→item_completedwithitem.type == "UserMessage"(24 items). The same files contain 203 records with a user role, most of them injected context. - Hermes (
~/.hermes/state.db,messagestable): ordinary user messages havedisplay_kindempty (200 rows); non-empty values are operational (model_switch, 3 rows); summaries carryrole='user'with_compressed_summary=1(14 rows).
Consequence: counting and scoring in Team Improvement are inflated by system and injected text, and any downstream consumer (e.g. a tool that wants the person's own words) cannot tell which records are actually typed input.
Proposed Solution
Parse by the source of the message rather than by role alone, and expose the result:
- Claude Code:
type=usertext that is not a tool result, notisMeta, notisCompactSummary, and does not begin with<system-reminder>,<task-notification>, an interruption marker or a command marker. - Codex:
event_msg→item_completedwithitem.type == "UserMessage"(keep a version check; older recordings useuser_message). - Hermes:
role='user',display_kindempty,_compressed_summary=0.
If a transcript does not match the expected shape, report it and fail loudly rather than silently skipping the file; a count of unparsed lines in each report would make drift visible.
Alternatives Considered
- Filtering by known injection prefixes only: brittle, misses new kinds.
- Leaving it as is and documenting the caveat: metrics keep including system text.
Additional Context
Version 0.30.0, macOS. Transcript shapes are internal formats and change between releases; a per-version criteria table with a safe default would keep this maintainable.
Activity
mosifu commentedon Nov 20, 2026
I'd like to take this. One scoping question before I write code, because the two answers change the shape of the patch.
Where the inflation can come from. The hook path already drops injected prompts:
dashboard-collector.ts:1153runs everyprompt_submitthroughstripInjectedPrompt(types.ts:2513, prefixes<task-notification>,<system-reminder>, the interrupt marker), and a purely injected prompt returnsnull, so it never reaches the event or the prompt count. Your measurement therefore has to come from a consumer that reads the native store directly rather than from events — the session census/score path — and I have not pinned that consumer down yet.So:/n/n1. Do you want the predicate in the adapters (
packages/tool-*/src/sessions.ts, next to the existingisMetahandling) and the metric switched to it, or a marker on the converted message (metadata.synthetic) with each consumer filtering? The marker keeps the archive andsession migratefaithful and moves the decision to the consumer; the predicate changes what a read returns.2. One PR for the three parsers, or three PRs (Claude Code first, then Codex, then Hermes)? They share no code, and the Codex one also needs the
item_completed/UserMessageversion check you mention.If you would rather I just pick, I will start with Claude Code alone, as a marker plus the one consumer that counts, and follow up with the other two.
Luckyou-d commentedon Nov 20, 2026
Taking the
isCompactSummaryhalf of this: Claude writes the compaction summary into the transcript in the user role, andisHumanPromptEntryonly filteredisMeta/isSidechain, so each compaction counted as a member turn and inflated the prompt count. Sent a PR that reads the flag and skips those entries (false/absent unchanged), with a test that fails onmain.Deliberately not in that PR, so they get their own decisions/fixtures: the Codex (
event_msg->item_completed,item.type == "UserMessage") and Hermes (display_kind/_compressed_summary) parsers, and the slash-command markers -session-scoring.test.tscurrently pins<command-name>/review-notes</command-name>as the member's first prompt, so excluding it would change intended behaviour and is worth a maintainer call.Please assign @Luckyou-d if available.
HengYangDS commentedon Nov 20, 2026
Thanks for taking this. Separate PRs, Claude Code first, sounds right, and so does the marker: let each adapter mark what it knows is not typed by the person, and let the counting skip marked messages. Since someone else picked up the compaction-summary half, could you two agree on who does which so the marker is set in one place?
XY-code1 commentedon Nov 23, 2026
@mosifu Are you already working on the Codex part of this issue? I'd like to take just that adapter if it's free. I'll leave Claude Code (#2003) and Hermes out of scope, and start with sanitized fixtures for both older and newer Codex transcript formats. The goal is to distinguish human input from injected context for counting without dropping the original transcript content.
HengYangDS commentedon Nov 25, 2026
Thanks for splitting this across the three adapters. #2003 covers Claude compaction summaries. #2034 uses turn IDs where available to keep a matching injected Codex row from consuming the human-input marker. #2039 adds a fallback for older Hermes databases that lack the classification columns.
Before closing this, could we compare the prompt count and derived scoring on the same transcript for each adapter, with one typed prompt and one injected or operational row? For Codex, #2034 still lists dashboard counters and real CLI verification as open. For Hermes, please verify that the source transcript remains readable and that the exclusion applies to what counts as typed input. A slash command the person actually typed should still count, while the material it loads should stay out of that count.