Skip to content

Commit 9701d4d

Browse files
committed
refactor(scout-agent): remove maxTokenThreshold option
maxTokenThreshold was only used for display in the warning message. Simplified to just use warningThreshold for both triggering and display.
1 parent 3da054d commit 9701d4d

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

packages/scout-agent/lib/core.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ describe("compaction", () => {
10801080
compaction: {
10811081
// Set a very low threshold so any message exceeds it
10821082
warningThreshold: 1,
1083-
maxTokenThreshold: 100,
10841083
},
10851084
});
10861085

@@ -1178,7 +1177,6 @@ describe("compaction", () => {
11781177
model: newMockModel({ textResponse: "test" }),
11791178
compaction: {
11801179
warningThreshold: 1_000_000, // Very high threshold
1181-
maxTokenThreshold: 2_000_000,
11821180
},
11831181
});
11841182

packages/scout-agent/lib/core.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,9 @@ export interface BuildStreamTextParamsOptions {
7272
* Token threshold at which to show a compaction warning.
7373
* When the conversation exceeds this threshold, a warning message
7474
* is injected asking the model to call the compact_conversation tool.
75-
* Default: 80% of maxTokenThreshold (80,000 tokens)
75+
* Default: 80,000 tokens
7676
*/
7777
warningThreshold?: number;
78-
/**
79-
* Maximum token threshold for the conversation.
80-
* Used to calculate the percentage in the warning message.
81-
* Default: 100,000 tokens
82-
*/
83-
maxTokenThreshold?: number;
8478
/**
8579
* Model name used for token counting.
8680
* Default: derived from the model parameter or "anthropic/claude-sonnet-4"
@@ -383,12 +377,9 @@ export class Scout {
383377

384378
// Determine if compaction is enabled and get config values
385379
const compactionEnabled = compactionConfig !== false;
386-
const maxTokenThreshold =
387-
(compactionConfig !== false && compactionConfig?.maxTokenThreshold) ||
388-
DEFAULT_TOKEN_THRESHOLD;
389380
const warningThreshold =
390381
(compactionConfig !== false && compactionConfig?.warningThreshold) ||
391-
Math.floor(maxTokenThreshold * 0.8);
382+
Math.floor(DEFAULT_TOKEN_THRESHOLD * 0.8);
392383
const compactionModelName =
393384
(compactionConfig !== false && compactionConfig?.modelName) ||
394385
(typeof model === "object" && "modelId" in model
@@ -428,7 +419,7 @@ export class Scout {
428419
// Inject a compaction warning message at the end of the conversation
429420
const warningMessage = createCompactionWarningMessage(
430421
tokenCount,
431-
maxTokenThreshold
422+
warningThreshold
432423
);
433424
compactedMessages = [...compactedMessages, warningMessage];
434425
compactionWarningInjected = true;

0 commit comments

Comments
 (0)