diff --git a/packages/core/src/context/config/profiles.ts b/packages/core/src/context/config/profiles.ts
index 662b88c2da..e938668500 100644
--- a/packages/core/src/context/config/profiles.ts
+++ b/packages/core/src/context/config/profiles.ts
@@ -88,24 +88,32 @@ export const generalistProfile: ContextProfile = {
}),
),
createBlobDegradationProcessor('BlobDegradation', env), // No options
+ // Automatically distill extremely large blocks (e.g. huge source files pasted by the user)
+ createNodeDistillationProcessor(
+ 'ImmediateNodeDistillation',
+ env,
+ resolveProcessorOptions(config, 'ImmediateNodeDistillation', {
+ nodeThresholdTokens: 15000,
+ }),
+ ),
],
},
{
name: 'Normalization',
triggers: ['retained_exceeded'],
processors: [
- createNodeTruncationProcessor(
- 'NodeTruncation',
- env,
- resolveProcessorOptions(config, 'NodeTruncation', {
- maxTokensPerNode: 3000,
- }),
- ),
createNodeDistillationProcessor(
'NodeDistillation',
env,
resolveProcessorOptions(config, 'NodeDistillation', {
- nodeThresholdTokens: 5000,
+ nodeThresholdTokens: 3000,
+ }),
+ ),
+ createNodeTruncationProcessor(
+ 'NodeTruncation',
+ env,
+ resolveProcessorOptions(config, 'NodeTruncation', {
+ maxTokensPerNode: 2000,
}),
),
],
diff --git a/packages/core/src/context/processors/toolMaskingProcessor.ts b/packages/core/src/context/processors/toolMaskingProcessor.ts
index 1ce07d1f6c..af960f0d0b 100644
--- a/packages/core/src/context/processors/toolMaskingProcessor.ts
+++ b/packages/core/src/context/processors/toolMaskingProcessor.ts
@@ -129,7 +129,10 @@ export function createToolMaskingProcessor(
1024
).toFixed(2);
const totalLines = content.split('\n').length;
- return `\n[Tool ${nodeType} string (${fileSizeMB}MB, ${totalLines} lines) masked to preserve context window. Full string saved to: ${filePath}]\n`;
+
+ // Ensure consistent path separators for LLM tokenization and deterministic tests across OSes
+ const normalizedPath = filePath.split(path.sep).join('/');
+ return `\n[Tool ${nodeType} string (${fileSizeMB}MB, ${totalLines} lines) masked to preserve context window. Full string saved to: ${normalizedPath}]\n`;
};
const returnedNodes: ConcreteNode[] = [];
diff --git a/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap b/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap
index cc63c4c177..9174cfb727 100644
--- a/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap
+++ b/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap
@@ -43,12 +43,12 @@ exports[`System Lifecycle Golden Tests > Scenario 1: Organic Growth with Huge To
"turnIndex": 1,
},
{
- "tokensAfterBackground": 436,
+ "tokensAfterBackground": 440,
"tokensBeforeBackground": 20148,
"turnIndex": 2,
},
{
- "tokensAfterBackground": 61,
+ "tokensAfterBackground": 62,
"tokensBeforeBackground": 3017,
"turnIndex": 3,
},
diff --git a/packages/core/src/context/system-tests/simulationHarness.ts b/packages/core/src/context/system-tests/simulationHarness.ts
index 2bf377f8cc..530ce0343e 100644
--- a/packages/core/src/context/system-tests/simulationHarness.ts
+++ b/packages/core/src/context/system-tests/simulationHarness.ts
@@ -35,7 +35,7 @@ export class SimulationHarness {
static async create(
config: ContextProfile,
mockLlmClient: BaseLlmClient,
- mockTempDir = '/tmp/sim',
+ mockTempDir = 'mock/sim/dir',
): Promise {
const harness = new SimulationHarness();
await harness.init(config, mockLlmClient, mockTempDir);