From 4039f06f708ba31dcbcc313ec487a019ca30bd79 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 17 Jun 2026 09:31:12 +0800 Subject: [PATCH] refactor(agents): remove unused command poll suggestion --- src/agents/command-poll-backoff.test.ts | 47 ------------------------- src/agents/command-poll-backoff.ts | 17 +-------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/agents/command-poll-backoff.test.ts b/src/agents/command-poll-backoff.test.ts index 1a7118cb43c..c3b8d34f21b 100644 --- a/src/agents/command-poll-backoff.test.ts +++ b/src/agents/command-poll-backoff.test.ts @@ -2,35 +2,12 @@ import { describe, expect, it } from "vitest"; import type { SessionState } from "../logging/diagnostic-session-state.js"; import { - calculateBackoffMs, - getCommandPollSuggestion, pruneStaleCommandPolls, recordCommandPoll, resetCommandPollCount, } from "./command-poll-backoff.js"; describe("command-poll-backoff", () => { - describe("calculateBackoffMs", () => { - it("returns 5s for first poll", () => { - expect(calculateBackoffMs(0)).toBe(5000); - }); - - it("returns 10s for second poll", () => { - expect(calculateBackoffMs(1)).toBe(10000); - }); - - it("returns 30s for third poll", () => { - expect(calculateBackoffMs(2)).toBe(30000); - }); - - it("returns 60s for fourth and subsequent polls (capped)", () => { - expect(calculateBackoffMs(3)).toBe(60000); - expect(calculateBackoffMs(4)).toBe(60000); - expect(calculateBackoffMs(10)).toBe(60000); - expect(calculateBackoffMs(100)).toBe(60000); - }); - }); - describe("recordCommandPoll", () => { it("returns 5s on first no-output poll", () => { const state: SessionState = { @@ -94,30 +71,6 @@ describe("command-poll-backoff", () => { }); }); - describe("getCommandPollSuggestion", () => { - it("returns undefined for untracked command", () => { - const state: SessionState = { - lastActivity: Date.now(), - state: "processing", - queueDepth: 0, - }; - expect(getCommandPollSuggestion(state, "unknown")).toBeUndefined(); - }); - - it("returns current backoff for tracked command", () => { - const state: SessionState = { - lastActivity: Date.now(), - state: "processing", - queueDepth: 0, - }; - - recordCommandPoll(state, "cmd-123", false); - recordCommandPoll(state, "cmd-123", false); - - expect(getCommandPollSuggestion(state, "cmd-123")).toBe(10000); - }); - }); - describe("resetCommandPollCount", () => { it("removes command from tracking", () => { const state: SessionState = { diff --git a/src/agents/command-poll-backoff.ts b/src/agents/command-poll-backoff.ts index 601d542eafa..7518ae36a73 100644 --- a/src/agents/command-poll-backoff.ts +++ b/src/agents/command-poll-backoff.ts @@ -10,7 +10,7 @@ const BACKOFF_SCHEDULE_MS = [5000, 10000, 30000, 60000]; * Calculate suggested retry delay based on consecutive no-output poll count. * Implements exponential backoff schedule: 5s → 10s → 30s → 60s (capped). */ -export function calculateBackoffMs(consecutiveNoOutputPolls: number): number { +function calculateBackoffMs(consecutiveNoOutputPolls: number): number { const index = Math.min(consecutiveNoOutputPolls, BACKOFF_SCHEDULE_MS.length - 1); return BACKOFF_SCHEDULE_MS[index] ?? 60000; } @@ -45,21 +45,6 @@ export function recordCommandPoll( return calculateBackoffMs(newCount); } -/** - * Get current suggested backoff for a command without modifying state. - * Useful for checking current backoff level. - */ -export function getCommandPollSuggestion( - state: SessionState, - commandId: string, -): number | undefined { - const pollData = state.commandPollCounts?.get(commandId); - if (!pollData) { - return undefined; - } - return calculateBackoffMs(pollData.count); -} - /** * Reset poll count for a command (e.g., when command completes). */