fix(agents): preserve cli session metadata before transcript persist (#67490)

This commit is contained in:
Ayaan Zaidi
2026-04-16 09:20:37 +05:30
parent c1817c62e3
commit 898fd0482a
2 changed files with 15 additions and 0 deletions

View File

@@ -1042,6 +1042,7 @@ async function agentCommandInternal(
fallbackModel,
result,
});
sessionEntry = sessionStore[sessionKey] ?? sessionEntry;
}
if (result.meta.executionTrace?.runner === "cli") {

View File

@@ -176,6 +176,14 @@ describe("agentCommand CLI provider handling", () => {
sessionId: "cli-session-123",
provider: "google-gemini-cli",
model: "gemini-3.1-pro-preview",
compactionCount: 2,
usage: {
input: 12,
output: 4,
cacheRead: 3,
cacheWrite: 0,
total: 19,
},
},
executionTrace: {
winnerProvider: "google-gemini-cli",
@@ -191,6 +199,12 @@ describe("agentCommand CLI provider handling", () => {
const saved = readSessionStore<{ sessionFile?: string }>(store);
const sessionFile = saved[sessionKey]?.sessionFile;
expect(sessionFile).toBeTruthy();
expect(saved[sessionKey]).toMatchObject({
compactionCount: 2,
inputTokens: 12,
outputTokens: 4,
cacheRead: 3,
});
const messages = await readSessionMessages(sessionFile!);
expect(messages).toHaveLength(2);