mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-12 16:08:59 +02:00
fix(memory-ingest): parse the current Codex response_item rollout shape
Fixes #2105. Codex rollout JSONL moved to { type: 'response_item', payload: { type: 'message', role, content: [...] } }; the parser's legacy payload.message branch never fired on it, so every Codex session imported as an empty shell (message_count: 0 — 243/243 sessions on the reporting machine). Both shapes now parse; non-message response_items (reasoning etc.) are ignored. parseTranscriptJsonl exported for direct unit tests (CLI path unchanged — import.meta.main guard). Note: #2104's staging-in-gitignored-tree half is already defended on main (--include-gitignored + GIT_CEILING_DIRECTORIES, #2144, plus the #2486 reconcile guard) — verified, no change needed; it moves to the close-only roster. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
c2cdf65176
commit
00d0115ac7
@@ -543,7 +543,7 @@ interface ParsedSession {
|
||||
partial: boolean;
|
||||
}
|
||||
|
||||
function parseTranscriptJsonl(path: string): ParsedSession | null {
|
||||
export function parseTranscriptJsonl(path: string): ParsedSession | null {
|
||||
// Best-effort tolerant parser. Handles truncated last lines (D10 partial-flag).
|
||||
let raw: string;
|
||||
try {
|
||||
@@ -619,7 +619,7 @@ function parseTranscriptJsonl(path: string): ParsedSession | null {
|
||||
const tool = rec?.name || rec?.tool || rec?.tool_call?.name || "tool";
|
||||
bodyParts.push(`### Tool call: ${tool}`);
|
||||
} else if (isCodex && rec?.payload?.message) {
|
||||
// Codex shape: each record has payload.message
|
||||
// Legacy Codex shape: each record has payload.message
|
||||
const msg = rec.payload.message;
|
||||
const role = msg.role || "user";
|
||||
const content = extractContentText(msg);
|
||||
@@ -627,6 +627,18 @@ function parseTranscriptJsonl(path: string): ParsedSession | null {
|
||||
bodyParts.push(`## ${role.charAt(0).toUpperCase() + role.slice(1)}\n\n${content}`);
|
||||
messageCount++;
|
||||
}
|
||||
} else if (isCodex && rec?.type === "response_item" && rec?.payload?.type === "message") {
|
||||
// Current Codex rollout shape (#2105): records are
|
||||
// { type: 'response_item', payload: { type: 'message', role, content: [...] } }.
|
||||
// The legacy payload.message branch never fires on these, which rendered
|
||||
// every Codex session as an empty shell (message_count: 0, 243/243 on
|
||||
// the reporting machine). Flatten payload.content like the Claude branch.
|
||||
const role = rec.payload.role || "user";
|
||||
const content = extractContentText(rec.payload);
|
||||
if (content) {
|
||||
bodyParts.push(`## ${role.charAt(0).toUpperCase() + role.slice(1)}\n\n${content}`);
|
||||
messageCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user