import { DefaultCompactionStrategy } from "@openharness/core";
// Tune the default strategy
const session = new Session({
agent,
contextWindow: 128_000,
compactionStrategy: new DefaultCompactionStrategy({
protectedTokens: 60_000, // protect more recent context
summaryModel: cheapModel, // use a cheaper model for summarization
}),
});
// Or replace the strategy entirely
const session = new Session({
agent,
contextWindow: 128_000,
compactionStrategy: {
async compact(context) {
// your own compaction logic
return { messages: [...], messagesRemoved: 0, tokensPruned: 0 };
},
},
});
// Or go fully manual
const session = new Session({ agent, autoCompact: false });
// ...later:
for await (const event of session.compact()) { /* ... */ }