Files
oh-my-opencode/src/hooks/preemptive-compaction.aws-bedrock.test.ts
T
YeonGyu-Kim 35df911919 test(hooks): update preemptive-compaction token thresholds for GA 1M context
Raise test token counts from 170K/180K to 800K/810K so compaction triggers at 78% of 1M instead of 78% of 200K, matching the actual GA context limit for 4.6 models.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-18 13:36:17 +09:00

65 lines
1.7 KiB
TypeScript

/// <reference types="bun-types" />
import { describe, expect, it, mock } from "bun:test"
import { OhMyOpenCodeConfigSchema } from "../config"
const { createPreemptiveCompactionHook } = await import("./preemptive-compaction")
type HookContext = Parameters<typeof createPreemptiveCompactionHook>[0]
function createMockContext(): HookContext {
return {
client: {
session: {
messages: mock(() => Promise.resolve({ data: [] })),
summarize: mock(() => Promise.resolve({})),
},
tui: {
showToast: mock(() => Promise.resolve()),
},
},
directory: "/tmp/test",
}
}
describe("preemptive-compaction aws-bedrock-anthropic", () => {
it("triggers compaction for aws-bedrock-anthropic provider when usage exceeds threshold", async () => {
// given
const ctx = createMockContext()
const pluginConfig = OhMyOpenCodeConfigSchema.parse({})
const hook = createPreemptiveCompactionHook(ctx, pluginConfig)
const sessionID = "ses_aws_bedrock_anthropic_high"
await hook.event({
event: {
type: "message.updated",
properties: {
info: {
role: "assistant",
sessionID,
providerID: "aws-bedrock-anthropic",
modelID: "claude-sonnet-4-6",
finish: true,
tokens: {
input: 800000,
output: 1000,
reasoning: 0,
cache: { read: 10000, write: 0 },
},
},
},
},
})
// when
await hook["tool.execute.after"](
{ tool: "bash", sessionID, callID: "call_aws_bedrock_1" },
{ title: "", output: "test", metadata: null },
)
// then
expect(ctx.client.session.summarize).toHaveBeenCalledTimes(1)
})
})