fix(agents): split preemptive compaction route types

This commit is contained in:
Vincent Koc
2026-04-12 00:13:11 +01:00
parent 3059b36306
commit 44e95065c4
3 changed files with 8 additions and 7 deletions

View File

@@ -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[];

View File

@@ -0,0 +1,5 @@
export type PreemptiveCompactionRoute =
| "fits"
| "compact_only"
| "truncate_tool_results_only"
| "compact_then_truncate";

View File

@@ -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,