feat(site/src/pages): show organization compaction at 80% of the override window

The organization override trigger now fires at a fixed 80% of the override model's context window, mirroring chatd, and no longer reads the override model's own compression threshold. Removes the notice for an override whose own compaction is off, and updates the settings popover, organization warning, fixtures, and tests to the new trigger.
This commit is contained in:
Michael Suchacz committed 2026-10-09 16:36:49 +00:00
1 parent 171d5f568e
commit 21d2ce7fce
7 files changed
+29 -48

No files matched your search

@@ -19,10 +19,6 @@ const alternateModel: TypesGen.ChatModel = {
model: "model-two",
display_name: "Model Two",
};
const mockDisabledCompactionModel: TypesGen.ChatModel = {
...MockCompactionChatModel,
compression_threshold: 100,
};
const mockTinyModelWithCompactionOff: TypesGen.ChatModel = {
...MockChatModel,
id: "tiny-model",
@@ -227,15 +223,6 @@ export const CompactionTriggerWarningWithoutCompactionOff: Story = {
play: CompactionTriggerWarning.play,
};
export const CompactionOverrideDisabledNotice: Story = {
args: {
overrides: [
{ context: "compaction", model_config_id: MockCompactionChatModel.id },
],
enabledModels: [mockDisabledCompactionModel, model],
},
};
export const CompactionTriggerWarningManyModels: Story = {
args: {
overrides: mockWarningOverrides,
@@ -111,22 +111,7 @@ const CompactionOverrideAlert: React.FC<CompactionOverrideAlertProps> = ({
"organization",
);
if (!organizationTrigger) {
const selectedModel = enabledModels.find(
(model) => model.id === selectedModelID,
);
if (
!selectedModel ||
selectedModel.compression_threshold < compactionDisabledThresholdPercent
) {
return null;
}
return (
<Alert severity="info">
<AlertDescription>
{`${getModelLabel(selectedModel)} has compaction off (${compactionDisabledThresholdPercent}%), so chats summarize with their own model instead.`}
</AlertDescription>
</Alert>
);
return null;
}
const compactionModel = organizationTrigger.model;
@@ -154,7 +139,7 @@ const CompactionOverrideAlert: React.FC<CompactionOverrideAlertProps> = ({
return (
<Alert severity="warning">
<AlertDescription>
{`Chats using ${formatModelList(undercutModels.map(getModelLabel))} may compact earlier than their models' thresholds${offModelsNote} because ${getModelLabel(compactionModel)} compacts at ${compactionModel.compression_threshold}% of its ${compactionModel.context_limit.toLocaleString("en-US")}-token window. Personal thresholds that trigger compaction sooner still apply first.`}
{`Chats using ${formatModelList(undercutModels.map(getModelLabel))} may compact earlier than their models' thresholds${offModelsNote} because ${getModelLabel(compactionModel)} compacts at ${organizationTrigger.trigger.thresholdPercent}% of its ${compactionModel.context_limit.toLocaleString("en-US")}-token window. Personal thresholds that trigger compaction sooner still apply first.`}
</AlertDescription>
</Alert>
);
@@ -27,7 +27,7 @@ const mockChatModel: TypesGen.ChatModel = {
};
const mockCompactionTrigger: OrganizationCompactionTrigger = {
model: MockCompactionChatModel,
trigger: { thresholdPercent: 50, contextLimit: 32_000 },
trigger: { thresholdPercent: 80, contextLimit: 20_000 },
pointTokens: 16_000,
};
const mockCompactionOverrides: TypesGen.ChatModelOverridesResponse = {
@@ -143,7 +143,7 @@ describe("compaction triggers", () => {
expect(isCompactionPointBeyondWindow(16_000, 0)).toBe(false);
});
it("resolves an enabled member-visible organization override model", () => {
it("resolves an enabled override at 80% of its window, ignoring its own threshold", () => {
expect(
resolveOrganizationCompactionTrigger(
MockCompactionChatModel.id,
@@ -178,7 +178,10 @@ describe("compaction triggers", () => {
[{ ...MockCompactionChatModel, compression_threshold: 100 }],
providers,
),
).toBeUndefined();
).toEqual({
...mockCompactionTrigger,
model: { ...MockCompactionChatModel, compression_threshold: 100 },
});
});
it("ignores an organization override model whose provider is disabled", () => {
@@ -314,11 +317,7 @@ describe("compaction triggers", () => {
{
models: [
mockChatModel,
{
...MockCompactionChatModel,
context_limit: 128_000,
compression_threshold: 90,
},
{ ...MockCompactionChatModel, context_limit: 128_000 },
],
userThresholds: [
{ model_config_id: mockChatModel.id, threshold_percent: 60 },
@@ -339,7 +338,7 @@ describe("compaction triggers", () => {
{
models: [
mockChatModel,
{ ...MockCompactionChatModel, context_limit: 256_000 },
{ ...MockCompactionChatModel, context_limit: 160_000 },
],
userThresholds: [
{ model_config_id: mockChatModel.id, threshold_percent: 100 },
@@ -32,6 +32,10 @@ export type ResolvedCompactionThreshold =
export const compactionDisabledThresholdPercent = 100;
// Mirrors chatd compactionOverrideWindowPercent: the remainder of the override
// window is left for the summary prompt and summary.
export const organizationOverrideWindowPercent = 80;
export const modelCompactionTrigger = (
model: TypesGen.ChatModel,
): CompactionTrigger => ({
@@ -105,7 +109,10 @@ export const resolveOrganizationCompactionTrigger = (
return undefined;
}
const trigger = modelCompactionTrigger(model);
const trigger = {
thresholdPercent: organizationOverrideWindowPercent,
contextLimit: model.context_limit,
};
if (!isCompactionTriggerEnabled(trigger)) {
return undefined;
}
@@ -15,8 +15,8 @@ import {
withDashboardProvider,
} from "#/testHelpers/storybook";
import {
modelCompactionTrigger,
type OrganizationCompactionTrigger,
organizationOverrideWindowPercent,
} from "../compactionTriggers";
import { UserCompactionThresholdSettings } from "./UserCompactionThresholdSettings";
@@ -35,8 +35,11 @@ const organizationTriggerFor = (
model: TypesGen.ChatModel,
): OrganizationCompactionTrigger => ({
model,
trigger: modelCompactionTrigger(model),
pointTokens: (model.context_limit * model.compression_threshold) / 100,
trigger: {
thresholdPercent: organizationOverrideWindowPercent,
contextLimit: model.context_limit,
},
pointTokens: (model.context_limit * organizationOverrideWindowPercent) / 100,
});
const mockCompactionTrigger = organizationTriggerFor(MockCompactionChatModel);
const mockCompactionTriggersByOrganizationID = new Map([
@@ -274,7 +277,7 @@ export const OrganizationTriggerWarningAtDisabledThreshold: Story = {
MockChatModel.organization_id,
organizationTriggerFor({
...MockCompactionChatModel,
context_limit: 256_000,
context_limit: 160_000,
}),
],
]),
@@ -204,8 +204,8 @@ const EffectiveCompactionThreshold: React.FC<
<>
{organizationModelName} compacts at{" "}
{organizationTrigger.pointTokens.toLocaleString("en-US")}{" "}
tokens ({organizationTrigger.model.compression_threshold}%
of its {organizationWindowLabel}-token window), beyond this
tokens ({organizationTrigger.trigger.thresholdPercent}% of
its {organizationWindowLabel}-token window), beyond this
model&apos;s{" "}
{modelConfig.context_limit.toLocaleString("en-US")}
-token window. Chats with this model do not compact
@@ -215,7 +215,7 @@ const EffectiveCompactionThreshold: React.FC<
) : (
<>
{organizationModelName} compacts at{" "}
{organizationTrigger.model.compression_threshold}% of its{" "}
{organizationTrigger.trigger.thresholdPercent}% of its{" "}
{organizationWindowLabel}-token window, about{" "}
{organizationTriggerPercentLabel}% of this model&apos;s
window.
+1 -1
View File
@@ -29,7 +29,7 @@ export const MockCompactionChatModel: ChatModel = {
id: "compaction-model",
model: "compact-mini",
display_name: "Compact Mini",
context_limit: 32_000,
context_limit: 20_000,
compression_threshold: 50,
};