refactor(agents): remove stale compaction grace helper

This commit is contained in:
Vincent Koc
2026-06-17 10:40:20 +08:00
parent 71fbddd2bb
commit 20ea7a055e
3 changed files with 3 additions and 28 deletions
@@ -832,13 +832,6 @@ vi.mock("./compaction-retry-aggregate-timeout.js", () => ({
vi.mock("./compaction-timeout.js", () => ({
resolveRunTimeoutDuringCompaction: () => "abort",
resolveRunTimeoutWithCompactionGraceMs: ({
runTimeoutMs,
compactionTimeoutMs,
}: {
runTimeoutMs: number;
compactionTimeoutMs: number;
}) => runTimeoutMs + compactionTimeoutMs,
selectCompactionTimeoutSnapshot: ({
currentSnapshot,
currentSessionId,
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest";
import { castAgentMessage } from "../../test-helpers/agent-message-fixtures.js";
import {
resolveRunTimeoutDuringCompaction,
resolveRunTimeoutWithCompactionGraceMs,
selectCompactionTimeoutSnapshot,
shouldFlagCompactionTimeout,
} from "./compaction-timeout.js";
@@ -90,15 +89,6 @@ describe("compaction-timeout helpers", () => {
).toBe("abort");
});
it("adds one compaction grace window to the run timeout budget", () => {
expect(
resolveRunTimeoutWithCompactionGraceMs({
runTimeoutMs: 600_000,
compactionTimeoutMs: 900_000,
}),
).toBe(1_500_000);
});
it("uses pre-compaction snapshot when compaction timeout occurs", () => {
const pre = [castAgentMessage({ role: "user", content: "pre" })] as const;
const current = [castAgentMessage({ role: "assistant", content: "current" })] as const;
@@ -4,7 +4,7 @@
import type { AgentMessage } from "../../runtime/index.js";
/** Timeout state used to distinguish normal run deadlines from compaction stalls. */
export type CompactionTimeoutSignal = {
type CompactionTimeoutSignal = {
isTimeout: boolean;
isCompactionPendingOrRetrying: boolean;
isCompactionInFlight: boolean;
@@ -34,16 +34,8 @@ export function resolveRunTimeoutDuringCompaction(params: {
return params.graceAlreadyUsed ? "abort" : "extend";
}
/** Effective run timeout after adding the one-time compaction grace budget. */
export function resolveRunTimeoutWithCompactionGraceMs(params: {
runTimeoutMs: number;
compactionTimeoutMs: number;
}): number {
return params.runTimeoutMs + params.compactionTimeoutMs;
}
/** Candidate transcript snapshots available when a timeout fires during compaction. */
export type SnapshotSelectionParams = {
type SnapshotSelectionParams = {
timedOutDuringCompaction: boolean;
preCompactionSnapshot: AgentMessage[] | null;
preCompactionSessionId: string;
@@ -52,7 +44,7 @@ export type SnapshotSelectionParams = {
};
/** Snapshot chosen for retry/replay after a compaction-related timeout. */
export type SnapshotSelection = {
type SnapshotSelection = {
messagesSnapshot: AgentMessage[];
sessionIdUsed: string;
source: "pre-compaction" | "current";