Skip to content

feat: parse full response_item transcript coverage (#13) - #37

Open
ayushsingh82 wants to merge 1 commit into
supermemoryai:mainfrom
ayushsingh82:feat/codex-response-item-transcript-coverage
Open

feat: parse full response_item transcript coverage (#13)#37
ayushsingh82 wants to merge 1 commit into
supermemoryai:mainfrom
ayushsingh82:feat/codex-response-item-transcript-coverage

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Summary

Addresses part 1 of #13 (the transcript-coverage half; the per-project tag override half is a separate, larger change and not included here).

parseTranscript() in src/services/transcript.ts only recognized response_item entries with payload.role === "assistant", and only extracted output_text content blocks. Recent Codex JSONL transcripts also carry, per #13:

  • user messages as response_item.payload.type === "message" with role: "user" and input_text content blocks — previously dropped entirely
  • assistant messages using text blocks in addition to output_texttext blocks were previously dropped
  • function_call entries (tool invocations) — previously dropped entirely
  • function_call_output entries (tool results) — previously dropped entirely

On a transcript that's mostly response_item-shaped rather than legacy event_msg-shaped, automatic capture could miss user intent and tool context.

Changes

  • parseTranscript() now extracts all of the above. Tool calls/results are recorded as bounded, truncated "tool"-role entries (capped at 500 chars with a truncated, N more chars marker) rather than raw unbounded output, per the issue's ask to filter/truncate tool context.
  • Since a rollout file can log the same turn in both the legacy event_msg shape and the current response_item shape, entries are now deduped when an identical (role, content) pair recurs within a small line window — so the same turn isn't captured twice.
  • signals.ts's groupEntriesIntoTurns() now carries "tool" entries into a turn's captured content, but doesn't scan them for signal keywords — bounded tool output is noisy and shouldn't itself trigger a capture.
  • build.mjs now also emits transcript.js as a standalone dist/services/transcript.js bundle (same pattern already used for session.js/tags.js/resultMerge.js), so this could be tested against real JSONL fixtures instead of only through the hook binaries.

Test plan

  • npm run typecheck — no new errors introduced by this change (4 pre-existing errors on main, unrelated to this file, are already being fixed in fix: don't lose capture delta on failed upload; restore clean typecheck #36)
  • npm test — 74/74 pass, including 6 new fixture-based tests in test/unit.mjs under "Codex transcript parsing":
    • extracts response_item user messages from input_text blocks
    • extracts response_item assistant messages from output_text and text blocks
    • captures function_call/function_call_output as bounded tool entries, verifying truncation
    • does not double-capture a turn logged as both event_msg and response_item
    • legacy event_msg-only transcripts still parse unchanged (regression guard)
    • an identical message repeated far apart (outside the dedup window) is still kept as two entries

…ai#13 part 1)

parseTranscript() only recognized response_item entries with
payload.role === "assistant", extracting just "output_text" content
blocks. Recent Codex JSONL transcripts also carry:

- user messages as response_item.payload.type === "message" with
  role: "user" and "input_text" content blocks
- assistant messages using "text" blocks in addition to "output_text"
- function_call entries (tool invocations)
- function_call_output entries (tool results)

None of these were captured, so automatic memory capture could miss
user intent and tool context on transcripts that are mostly
response_item-shaped rather than legacy event_msg-shaped.

parseTranscript() now handles all of the above, with tool calls/results
recorded as bounded, truncated "tool"-role entries (capped at 500 chars
with a truncation marker) rather than raw unbounded output. Since a
rollout file can log the same turn in both the legacy event_msg shape
and the current response_item shape, entries are deduped when an
identical (role, content) pair recurs within a small line window, so
turns aren't captured twice.

signals.ts's groupEntriesIntoTurns() now carries "tool" entries into
the turn's captured content without scanning them for signal keywords,
since bounded tool output is noisy and shouldn't itself trigger a
capture.

transcript.ts is now bundled to dist/services/transcript.js (same
pattern as session.js/tags.js/resultMerge.js) so this can be
unit-tested directly against real transcript fixtures instead of only
through the hook binaries.
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@Dhravya parses full response_item transcript coverage (user/tool messages that were previously dropped). Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant