Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/agent/compaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import {
COMPACT_SPACER_TEXT,
LEGACY_COMPACT_SPACER_TEXT,
compactorNoOpFloor,
COMPACT_NOOP_FLOOR,
} from "../session/compactor.js";
import { buildSummaryPrompt } from "../session/summarizer.js";

Expand Down Expand Up @@ -509,7 +509,7 @@ describe("compaction governor", () => {

test("never arms at the exact turn count createPruningCompactor no-ops on", () => {
// The compactor's own no-op floor; arming at or below it spends a cycle that shrinks nothing.
const floor = compactorNoOpFloor();
const floor = COMPACT_NOOP_FLOOR;
const governor = createCompactionGovernor(() => undefined);
governor.noteInferenceDone(
inferenceDone(overThreshold),
Expand All @@ -521,7 +521,7 @@ describe("compaction governor", () => {
});

test("arms one turn past the floor createPruningCompactor no-ops on", () => {
const floor = compactorNoOpFloor();
const floor = COMPACT_NOOP_FLOOR;
const governor = createCompactionGovernor(() => undefined);
governor.noteInferenceDone(
inferenceDone(overThreshold),
Expand Down
6 changes: 3 additions & 3 deletions src/agent/compaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "../provider/context-window.js";
import {
assistantTextIsCompactSpacerEcho,
compactorNoOpFloor,
COMPACT_NOOP_FLOOR,
isCompactSpacerEchoTurn,
} from "../session/compactor.js";
import {
Expand All @@ -24,9 +24,9 @@ import {
import { onTurnBoundary } from "./reactor-events.js";

const COMPACTOR_NAME = "pruning-compactor";
// Compactor no-op floor, from the same helper so it cannot drift; arming
// Compactor no-op floor, shared from the compactor so it cannot drift; arming
// at or below spends a cycle that shrinks nothing.
const MIN_TURNS_TO_COMPACT = compactorNoOpFloor();
const MIN_TURNS_TO_COMPACT = COMPACT_NOOP_FLOOR;
// Cap overflow retries so an unshrinkable history cannot loop forever;
// cleared once usage drops back under the watermark.
const MAX_OVERFLOW_RECOVERIES = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/agent/director.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { createPermissionGate } from "../permission/gate.js";
import {
COMPACT_SPACER_TEXT,
LEGACY_COMPACT_SPACER_TEXT,
compactorNoOpFloor,
COMPACT_NOOP_FLOOR,
} from "../session/compactor.js";
import {
INFERENCE_ABORT_INTERNAL_RECOVERY,
Expand Down Expand Up @@ -785,7 +785,7 @@ function makeToolErrorEvent(callId: string, content: string) {
// One turn past the compactor's no-op floor (session/compactor.ts), so the
// arming check finds history actually worth compacting.
const longState = {
turns: Array.from({ length: compactorNoOpFloor() + 1 }, () => ({
turns: Array.from({ length: COMPACT_NOOP_FLOOR + 1 }, () => ({
role: "user",
content: [],
timestamp: 0,
Expand Down
8 changes: 4 additions & 4 deletions src/context-compactor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defined } from "../testkit/defined.js";
import { describe, test, expect } from "bun:test";
import {
createPruningCompactor,
compactorNoOpFloor,
COMPACT_NOOP_FLOOR,
buildTurnSummary,
COMPACTED_PREFIX,
COMPACT_SPACER_TEXT,
Expand Down Expand Up @@ -93,15 +93,15 @@ describe("createPruningCompactor", () => {
expect(result.output).toBe(turns); // Same reference when no compaction needed
});

test("compactorNoOpFloor names the exact turn count apply() no-ops on", async () => {
// The compaction governor derives its arming floor from this function so
test("COMPACT_NOOP_FLOOR names the exact turn count apply() no-ops on", async () => {
// The compaction governor derives its arming floor from this constant so
// it never arms a compaction guaranteed to no-op; changing apply()'s
// no-op condition without updating the floor breaks that guarantee
// silently.
const compactor = smallCompactor({
summaryMaxChars: 500,
});
const floor = compactorNoOpFloor();
const floor = COMPACT_NOOP_FLOOR;

// Bodies exceed the pinned tail budget, so past-floor always has a folded
// region while at-floor still no-ops on the count check alone.
Expand Down
6 changes: 2 additions & 4 deletions src/session/compactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ function extraInstructionParameter(
}

// `apply` no-ops at or below this turn count: one turn cannot shrink.
export function compactorNoOpFloor(): number {
return 1;
}
export const COMPACT_NOOP_FLOOR = 1;

// Query tools dedup by full-argument identity: a later identical call
// reflects newer workspace state, so older results are stale. run_shell is
Expand Down Expand Up @@ -884,7 +882,7 @@ export function createPruningCompactor(
// Prior compacted summaries fold into the next handoff, not frozen.
const shape = resolveCompactionShape(cfg.compactionShape);

if (turns.length <= compactorNoOpFloor()) {
if (turns.length <= COMPACT_NOOP_FLOOR) {
return {
output: turns,
record: {
Expand Down
4 changes: 2 additions & 2 deletions src/subagent/nudge-director.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ReactorState,
} from "@intx/types/runtime";
import { createCorbitsRetryPolicy } from "../agent/retry-policy.js";
import { compactorNoOpFloor } from "../session/compactor.js";
import { COMPACT_NOOP_FLOOR } from "../session/compactor.js";
import { SubAgentDirector } from "./nudge-director.js";
import type { AdmissionQueue } from "./admission.js";
import { createTestCapabilities } from "./director-test-harness.js";
Expand All @@ -19,7 +19,7 @@ import {

const state = { turns: [] } as unknown as ReactorState;
const longState = {
turns: Array.from({ length: compactorNoOpFloor() + 1 }, () => ({
turns: Array.from({ length: COMPACT_NOOP_FLOOR + 1 }, () => ({
role: "user",
content: [],
timestamp: 0,
Expand Down
Loading