From 44e95065c4f51b633791c331ce4f452f1fc7fb86 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 12 Apr 2026 00:13:11 +0100 Subject: [PATCH] fix(agents): split preemptive compaction route types --- .../pi-embedded-runner/run/preemptive-compaction.ts | 8 ++------ .../pi-embedded-runner/run/preemptive-compaction.types.ts | 5 +++++ src/agents/pi-embedded-runner/run/types.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 src/agents/pi-embedded-runner/run/preemptive-compaction.types.ts diff --git a/src/agents/pi-embedded-runner/run/preemptive-compaction.ts b/src/agents/pi-embedded-runner/run/preemptive-compaction.ts index e0cf8073f33..a1baa6487c2 100644 --- a/src/agents/pi-embedded-runner/run/preemptive-compaction.ts +++ b/src/agents/pi-embedded-runner/run/preemptive-compaction.ts @@ -2,18 +2,14 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { estimateTokens } from "@mariozechner/pi-coding-agent"; import { SAFETY_MARGIN, estimateMessagesTokens } from "../../compaction.js"; import { estimateToolResultReductionPotential } from "../tool-result-truncation.js"; +import type { PreemptiveCompactionRoute } from "./preemptive-compaction.types.js"; export const PREEMPTIVE_OVERFLOW_ERROR_TEXT = "Context overflow: prompt too large for the model (precheck)."; const ESTIMATED_CHARS_PER_TOKEN = 4; const TRUNCATION_ROUTE_BUFFER_TOKENS = 512; - -export type PreemptiveCompactionRoute = - | "fits" - | "compact_only" - | "truncate_tool_results_only" - | "compact_then_truncate"; +export type { PreemptiveCompactionRoute } from "./preemptive-compaction.types.js"; export function estimatePrePromptTokens(params: { messages: AgentMessage[]; diff --git a/src/agents/pi-embedded-runner/run/preemptive-compaction.types.ts b/src/agents/pi-embedded-runner/run/preemptive-compaction.types.ts new file mode 100644 index 00000000000..f1bb114e635 --- /dev/null +++ b/src/agents/pi-embedded-runner/run/preemptive-compaction.types.ts @@ -0,0 +1,5 @@ +export type PreemptiveCompactionRoute = + | "fits" + | "compact_only" + | "truncate_tool_results_only" + | "compact_then_truncate"; diff --git a/src/agents/pi-embedded-runner/run/types.ts b/src/agents/pi-embedded-runner/run/types.ts index f6b19f125e9..c69b606bcf2 100644 --- a/src/agents/pi-embedded-runner/run/types.ts +++ b/src/agents/pi-embedded-runner/run/types.ts @@ -11,7 +11,7 @@ import type { NormalizedUsage } from "../../usage.js"; import type { EmbeddedRunReplayMetadata, EmbeddedRunReplayState } from "../replay-state.js"; import type { EmbeddedRunLivenessState } from "../types.js"; import type { RunEmbeddedPiAgentParams } from "./params.js"; -import type { PreemptiveCompactionRoute } from "./preemptive-compaction.js"; +import type { PreemptiveCompactionRoute } from "./preemptive-compaction.types.js"; type EmbeddedRunAttemptBase = Omit< RunEmbeddedPiAgentParams,