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
38 changes: 28 additions & 10 deletions assistant/src/__tests__/approval-cascade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,34 @@ mock.module("../providers/registry.js", () => ({

mock.module("../config/loader.js", () => ({
getConfig: () => ({
ui: {},
provider: "mock-provider",
maxTokens: 4096,
thinking: false,
contextWindow: {
maxInputTokens: 100000,
thresholdTokens: 80000,
preserveRecentMessages: 6,
summaryModel: "mock-model",
maxSummaryTokens: 512,
ui: {},
llm: {
default: {
provider: "mock-provider",
model: "mock-model",
maxTokens: 4096,
effort: "max" as const,
speed: "standard" as const,
temperature: null,
thinking: { enabled: false, streamThinking: true },
contextWindow: {
enabled: true,
maxInputTokens: 100000,
targetBudgetRatio: 0.3,
compactThreshold: 0.8,
summaryBudgetRatio: 0.05,
overflowRecovery: {
enabled: true,
safetyMarginRatio: 0.05,
maxAttempts: 3,
interactiveLatestTurnCompression: "summarize",
nonInteractiveLatestTurnCompression: "truncate",
},
},
},
profiles: {},
callSites: {},
pricingOverrides: [],
},
rateLimit: { maxRequestsPerMinute: 0 },
timeouts: { permissionTimeoutSec: 300 },
Expand Down
2 changes: 1 addition & 1 deletion assistant/src/__tests__/compaction.benchmark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function makeLongMessages(turns: number): Message[] {

function makeConfig() {
return {
...DEFAULT_CONFIG.contextWindow,
...DEFAULT_CONFIG.llm.default.contextWindow,
maxInputTokens: 6000,
targetBudgetRatio: 0.58,
compactThreshold: 0.6,
Expand Down
39 changes: 11 additions & 28 deletions assistant/src/__tests__/config-analysis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,27 @@ describe("AnalysisConfigSchema", () => {
const parsed = AnalysisConfigSchema.parse({});
expect(parsed.batchSize).toBe(30);
expect(parsed.idleTimeoutMs).toBe(600_000);
expect(parsed.modelIntent).toBeUndefined();
expect(parsed.modelOverride).toBeUndefined();
});

test("custom values round-trip", () => {
test("custom batch/idle values round-trip", () => {
const input = {
batchSize: 50,
idleTimeoutMs: 120_000,
modelIntent: "quality-optimized" as const,
modelOverride: "anthropic/claude-opus-4-6",
};
const parsed = AnalysisConfigSchema.parse(input);
expect(parsed).toEqual(input);
});

test("accepts each valid modelIntent value", () => {
for (const intent of [
"latency-optimized",
"quality-optimized",
"vision-optimized",
] as const) {
const parsed = AnalysisConfigSchema.parse({ modelIntent: intent });
expect(parsed.modelIntent).toBe(intent);
}
test("legacy modelIntent/modelOverride are stripped after PR 19 cleanup", () => {
// Both fields moved to llm.callSites.analyzeConversation in PR 4 and
// were removed from the schema in PR 19. Zod silently strips unknown
// keys; migration 039 erases them from disk.
const parsed = AnalysisConfigSchema.parse({
modelIntent: "quality-optimized",
modelOverride: "anthropic/claude-opus-4-6",
});
expect((parsed as Record<string, unknown>).modelIntent).toBeUndefined();
expect((parsed as Record<string, unknown>).modelOverride).toBeUndefined();
});

test("rejects batchSize: 0 (must be positive)", () => {
Expand All @@ -60,18 +57,6 @@ describe("AnalysisConfigSchema", () => {
const result = AnalysisConfigSchema.safeParse({ idleTimeoutMs: -1000 });
expect(result.success).toBe(false);
});

test("rejects invalid modelIntent value", () => {
const result = AnalysisConfigSchema.safeParse({
modelIntent: "bogus-intent",
});
expect(result.success).toBe(false);
});

test("rejects non-string modelOverride", () => {
const result = AnalysisConfigSchema.safeParse({ modelOverride: 42 });
expect(result.success).toBe(false);
});
});

describe("AssistantConfigSchema — analysis integration", () => {
Expand All @@ -88,13 +73,11 @@ describe("AssistantConfigSchema — analysis integration", () => {
analysis: {
batchSize: 15,
idleTimeoutMs: 300_000,
modelIntent: "latency-optimized",
},
});
expect(parsed.analysis).toEqual({
batchSize: 15,
idleTimeoutMs: 300_000,
modelIntent: "latency-optimized",
});
});
});
Loading
Loading