@springbrand/agent-runtime 0.3.0-alpha.19 → 0.3.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -153,10 +153,9 @@ export class HarnessRuntimeConfig {
|
|
|
153
153
|
platform: state.snapshot.bindings.platform,
|
|
154
154
|
compaction: {
|
|
155
155
|
enabled: true,
|
|
156
|
-
// Pi compacts above contextWindow - reserveTokens.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
(state.snapshot.pi.model.contextWindow - state.snapshot.pi.model.maxTokens) * 0.85),
|
|
156
|
+
// Pi compacts above contextWindow - reserveTokens.
|
|
157
|
+
reserveTokens: state.snapshot.pi.model.contextWindow -
|
|
158
|
+
compactionThreshold(state.snapshot.pi.model),
|
|
160
159
|
keepRecentTokens: Math.min(
|
|
161
160
|
20_000,
|
|
162
161
|
Math.floor(state.snapshot.pi.model.contextWindow * 0.15),
|
|
@@ -201,3 +200,21 @@ export type {
|
|
|
201
200
|
PreparePiRuntimeOptions,
|
|
202
201
|
PreparedPiRuntime,
|
|
203
202
|
} from "./pinning";
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Input tokens above which a Turn compacts its history.
|
|
206
|
+
*
|
|
207
|
+
* OpenRouter rejects some requests well below a model's advertised window
|
|
208
|
+
* (seen from about 393k tokens on DeepSeek V4.1 Flash and 520k-630k on GPT-6
|
|
209
|
+
* Luna), before any provider is chosen. No model waits past this cap, so long
|
|
210
|
+
* Chats compact instead of failing.
|
|
211
|
+
*/
|
|
212
|
+
export const MAX_COMPACTION_THRESHOLD_TOKENS = 300_000;
|
|
213
|
+
|
|
214
|
+
/** 15% headroom within the input budget, capped at {@link MAX_COMPACTION_THRESHOLD_TOKENS}. */
|
|
215
|
+
export function compactionThreshold(model: { contextWindow: number; maxTokens: number }): number {
|
|
216
|
+
return Math.min(
|
|
217
|
+
Math.floor((model.contextWindow - model.maxTokens) * 0.85),
|
|
218
|
+
MAX_COMPACTION_THRESHOLD_TOKENS,
|
|
219
|
+
);
|
|
220
|
+
}
|