fix(agents): avoid synthetic tool-result writes on idle-timeout cleanup

This commit is contained in:
Vignesh Natarajan
2026-03-05 19:29:18 -08:00
parent 81b93b9ce0
commit 4daaea1190
8 changed files with 71 additions and 7 deletions

View File

@@ -9,6 +9,8 @@ import { installSessionToolResultGuard } from "./session-tool-result-guard.js";
export type GuardedSessionManager = SessionManager & {
/** Flush any synthetic tool results for pending tool calls. Idempotent. */
flushPendingToolResults?: () => void;
/** Clear pending tool calls without persisting synthetic tool results. Idempotent. */
clearPendingToolResults?: () => void;
};
/**
@@ -69,5 +71,6 @@ export function guardSessionManager(
beforeMessageWriteHook: beforeMessageWrite,
});
(sessionManager as GuardedSessionManager).flushPendingToolResults = guard.flushPendingToolResults;
(sessionManager as GuardedSessionManager).clearPendingToolResults = guard.clearPendingToolResults;
return sessionManager as GuardedSessionManager;
}