hmm speculative

This commit is contained in:
Your Name
2026-04-08 20:27:00 +00:00
parent 57f13a196e
commit 42022279bb
12 changed files with 321 additions and 211 deletions
@@ -4,8 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { testTruncateProfile } from './sidecar/testProfile.js';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { testTruncateProfile } from './sidecar/testProfile.js';
import {
createSyntheticHistory,
createMockContextConfig,
@@ -25,7 +27,10 @@ describe('ContextManager Sync Pressure Barrier Tests', () => {
it('should instantly truncate history when maxTokens is exceeded using truncate strategy', async () => {
// 1. Setup
const config = createMockContextConfig();
const { chatHistory, contextManager } = setupContextComponentTest(config);
const { chatHistory, contextManager } = setupContextComponentTest(
config,
testTruncateProfile,
);
// 2. Add System Prompt (Episode 0 - Protected)
chatHistory.set([
@@ -60,9 +65,15 @@ describe('ContextManager Sync Pressure Barrier Tests', () => {
expect(projection[0].role).toBe('user');
expect(projection[0].parts![0].text).toBe('System prompt');
// Filter out synthetic Yield nodes (they are model responses without actual tool/text bodies)
const contentNodes = projection.filter(
(p) =>
p.parts && p.parts.some((part) => part.text && part.text !== 'Yield'),
);
// Verify the latest turn is perfectly preserved at the back
const lastUser = projection[projection.length - 2];
const lastModel = projection[projection.length - 1];
const lastUser = contentNodes[contentNodes.length - 2];
const lastModel = contentNodes[contentNodes.length - 1];
expect(lastUser.role).toBe('user');
expect(lastUser.parts![0].text).toBe('Final question.');