mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 07:12:12 +03:00
fix: also apply adjacency guard inside compressContext
compressContext calls fixToolPairs but was missing fixToolAdjacency and stripTrailingAssistantOrphanToolUse, leaving orphan tool_use blocks when context pruning splits tool_use/tool_result pairs. Co-Authored-By: OpenClaude (mimo-v2.5-pro) <openclaude@gitlawb.com>
This commit is contained in:
@@ -266,6 +266,8 @@ function purifyHistory(messages: Record<string, unknown>[], targetTokens: number
|
||||
while (keep > 2) {
|
||||
let candidate = [...system, ...nonSystem.slice(-keep)];
|
||||
candidate = fixToolPairs(candidate);
|
||||
candidate = fixToolAdjacency(candidate);
|
||||
candidate = stripTrailingAssistantOrphanToolUse(candidate);
|
||||
const tokens = estimateTokens(JSON.stringify(candidate));
|
||||
if (tokens <= targetTokens) break;
|
||||
keep = Math.max(2, Math.floor(keep * 0.7)); // Drop 30% each iteration
|
||||
@@ -273,6 +275,8 @@ function purifyHistory(messages: Record<string, unknown>[], targetTokens: number
|
||||
|
||||
let result = [...system, ...nonSystem.slice(-keep)];
|
||||
result = fixToolPairs(result);
|
||||
result = fixToolAdjacency(result);
|
||||
result = stripTrailingAssistantOrphanToolUse(result);
|
||||
|
||||
// Add summary of dropped messages
|
||||
if (keep < nonSystem.length) {
|
||||
|
||||
Reference in New Issue
Block a user