Skip to content

Commit e0af9c1

Browse files
committed
fix: make post-turn compaction non-fatal
If CLI compaction summarization fails after the assistant reply is already generated and persisted, the error should not discard the reply or surface the turn as a failure. Wrap compaction in try/catch so network errors from the summarizer don't kill the turn. (#94688)
1 parent 739636f commit e0af9c1

1 file changed

Lines changed: 28 additions & 22 deletions

File tree

‎src/agents/agent-command.ts‎

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,28 +2212,34 @@ async function agentCommandInternal(
22122212
);
22132213
}
22142214
if (persistedCliTurnTranscript && !suppressVisibleSessionEffects) {
2215-
sessionEntry = await (
2216-
await loadCliCompactionRuntime()
2217-
).runCliTurnCompactionLifecycle({
2218-
cfg,
2219-
sessionId: effectiveSessionId,
2220-
sessionKey: sessionKey ?? effectiveSessionId,
2221-
sessionEntry,
2222-
sessionStore,
2223-
storePath,
2224-
sessionAgentId,
2225-
workspaceDir,
2226-
cwd: effectiveCwd,
2227-
agentDir,
2228-
provider: result.meta.agentMeta?.provider ?? provider,
2229-
model: result.meta.agentMeta?.model ?? model,
2230-
skillsSnapshot,
2231-
messageChannel,
2232-
agentAccountId: runContext.accountId,
2233-
senderIsOwner: opts.senderIsOwner,
2234-
thinkLevel: resolvedThinkLevel,
2235-
extraSystemPrompt: opts.extraSystemPrompt,
2236-
});
2215+
try {
2216+
sessionEntry = await (
2217+
await loadCliCompactionRuntime()
2218+
).runCliTurnCompactionLifecycle({
2219+
cfg,
2220+
sessionId: effectiveSessionId,
2221+
sessionKey: sessionKey ?? effectiveSessionId,
2222+
sessionEntry,
2223+
sessionStore,
2224+
storePath,
2225+
sessionAgentId,
2226+
workspaceDir,
2227+
cwd: effectiveCwd,
2228+
agentDir,
2229+
provider: result.meta.agentMeta?.provider ?? provider,
2230+
model: result.meta.agentMeta?.model ?? model,
2231+
skillsSnapshot,
2232+
messageChannel,
2233+
agentAccountId: runContext.accountId,
2234+
senderIsOwner: opts.senderIsOwner,
2235+
thinkLevel: resolvedThinkLevel,
2236+
extraSystemPrompt: opts.extraSystemPrompt,
2237+
});
2238+
} catch {
2239+
// Post-turn compaction is best-effort; a failure (e.g. network
2240+
// error from the summarizer) should not discard the already-generated
2241+
// reply or surface the turn as a failure. (#94688)
2242+
}
22372243
}
22382244
}
22392245

0 commit comments

Comments
 (0)