open-agents-ai 0.64.0 → 0.65.0
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/dist/index.js +59 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13801,7 +13801,7 @@ Rules:
|
|
|
13801
13801
|
const keepRecentDivisor = tier === "small" ? 2e3 : tier === "medium" ? 3e3 : 4e3;
|
|
13802
13802
|
keepRecent = Math.max(4, Math.min(keepRecentMax, Math.floor(ctx / keepRecentDivisor)));
|
|
13803
13803
|
} else {
|
|
13804
|
-
keepRecent = deep ? 20 : 12;
|
|
13804
|
+
keepRecent = deep ? tier === "small" ? 8 : tier === "medium" ? 14 : 20 : tier === "small" ? 4 : tier === "medium" ? 6 : 12;
|
|
13805
13805
|
}
|
|
13806
13806
|
const maxOutputTokens = ctx > 0 ? Math.min(this.options.maxTokens, Math.max(2048, Math.floor(ctx * 0.25))) : this.options.maxTokens;
|
|
13807
13807
|
const toolOutputCeiling = deep ? 16e3 : 8e3;
|
|
@@ -14088,7 +14088,14 @@ Integrate this guidance into your current approach. Continue working on the task
|
|
|
14088
14088
|
const choiceContent = response.choices[0]?.message?.content ?? "";
|
|
14089
14089
|
const choiceArgs = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
|
|
14090
14090
|
estimatedTokens += Math.ceil((choiceContent.length + choiceArgs.length) / 4);
|
|
14091
|
-
const estimatedContextTokens = Math.ceil(compacted.reduce((sum, m) =>
|
|
14091
|
+
const estimatedContextTokens = Math.ceil(compacted.reduce((sum, m) => {
|
|
14092
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14093
|
+
if (m.tool_calls) {
|
|
14094
|
+
for (const tc of m.tool_calls)
|
|
14095
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14096
|
+
}
|
|
14097
|
+
return sum + chars;
|
|
14098
|
+
}, 0) / 4);
|
|
14092
14099
|
this.emit({
|
|
14093
14100
|
type: "token_usage",
|
|
14094
14101
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14386,7 +14393,14 @@ Integrate this guidance into your current approach. Continue working on the task
|
|
|
14386
14393
|
const choiceContent2 = response.choices[0]?.message?.content ?? "";
|
|
14387
14394
|
const choiceArgs2 = response.choices[0]?.message?.toolCalls?.map((tc) => JSON.stringify(tc.arguments)).join("") ?? "";
|
|
14388
14395
|
estimatedTokens += Math.ceil((choiceContent2.length + choiceArgs2.length) / 4);
|
|
14389
|
-
const bfEstCtx = Math.ceil(compactedMsgs.reduce((sum, m) =>
|
|
14396
|
+
const bfEstCtx = Math.ceil(compactedMsgs.reduce((sum, m) => {
|
|
14397
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14398
|
+
if (m.tool_calls) {
|
|
14399
|
+
for (const tc of m.tool_calls)
|
|
14400
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14401
|
+
}
|
|
14402
|
+
return sum + chars;
|
|
14403
|
+
}, 0) / 4);
|
|
14390
14404
|
this.emit({
|
|
14391
14405
|
type: "token_usage",
|
|
14392
14406
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14659,12 +14673,19 @@ ${tail}`;
|
|
|
14659
14673
|
if (messages.length < 3)
|
|
14660
14674
|
return messages;
|
|
14661
14675
|
const totalChars = messages.reduce((sum, m) => {
|
|
14676
|
+
let chars = 0;
|
|
14662
14677
|
if (typeof m.content === "string")
|
|
14663
|
-
|
|
14664
|
-
if (Array.isArray(m.content)) {
|
|
14665
|
-
|
|
14678
|
+
chars += m.content.length;
|
|
14679
|
+
else if (Array.isArray(m.content)) {
|
|
14680
|
+
chars += m.content.reduce((s, p) => s + (p.text?.length || 0) + (p.image_url ? 1e3 : 0), 0);
|
|
14681
|
+
}
|
|
14682
|
+
if (m.tool_calls) {
|
|
14683
|
+
for (const tc of m.tool_calls) {
|
|
14684
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14685
|
+
chars += tc.function.name?.length ?? 0;
|
|
14686
|
+
}
|
|
14666
14687
|
}
|
|
14667
|
-
return sum;
|
|
14688
|
+
return sum + chars;
|
|
14668
14689
|
}, 0);
|
|
14669
14690
|
const estimatedTokens = totalChars / 4;
|
|
14670
14691
|
const limits = this.contextLimits();
|
|
@@ -14758,7 +14779,34 @@ ${fullSummary}
|
|
|
14758
14779
|
[Continue from the recent context below. Do not repeat work already completed above.]`
|
|
14759
14780
|
};
|
|
14760
14781
|
this.persistCheckpoint(fullSummary);
|
|
14761
|
-
|
|
14782
|
+
let result = [...head, compactionMsg, ...recent];
|
|
14783
|
+
const ctxWindow = this.options.contextWindowSize;
|
|
14784
|
+
if (ctxWindow > 0) {
|
|
14785
|
+
const estimateResult = (msgs) => msgs.reduce((sum, m) => {
|
|
14786
|
+
let chars = typeof m.content === "string" ? m.content.length : 100;
|
|
14787
|
+
if (m.tool_calls) {
|
|
14788
|
+
for (const tc of m.tool_calls)
|
|
14789
|
+
chars += tc.function.arguments?.length ?? 0;
|
|
14790
|
+
}
|
|
14791
|
+
return sum + chars;
|
|
14792
|
+
}, 0) / 4;
|
|
14793
|
+
const safetyTarget = Math.floor(ctxWindow * 0.65);
|
|
14794
|
+
let trimmedRecent = [...recent];
|
|
14795
|
+
while (estimateResult(result) > safetyTarget && trimmedRecent.length > 2) {
|
|
14796
|
+
trimmedRecent = trimmedRecent.slice(1);
|
|
14797
|
+
while (trimmedRecent.length > 1 && trimmedRecent[0]?.role === "tool") {
|
|
14798
|
+
trimmedRecent = trimmedRecent.slice(1);
|
|
14799
|
+
}
|
|
14800
|
+
result = [...head, compactionMsg, ...trimmedRecent];
|
|
14801
|
+
}
|
|
14802
|
+
if (trimmedRecent.length < recent.length) {
|
|
14803
|
+
this.emit({
|
|
14804
|
+
type: "status",
|
|
14805
|
+
content: `Post-compaction trim: reduced recent from ${recent.length} to ${trimmedRecent.length} messages to fit ${ctxWindow.toLocaleString()}-token context window`,
|
|
14806
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14807
|
+
});
|
|
14808
|
+
}
|
|
14809
|
+
}
|
|
14762
14810
|
if (result.length < 2)
|
|
14763
14811
|
return messages;
|
|
14764
14812
|
return result;
|
|
@@ -35012,6 +35060,9 @@ async function startInteractive(config, repoPath) {
|
|
|
35012
35060
|
if (ctxSize) {
|
|
35013
35061
|
resolvedContextWindowSize = ctxSize;
|
|
35014
35062
|
statusBar.setContextWindowSize(ctxSize);
|
|
35063
|
+
if (activeTask) {
|
|
35064
|
+
activeTask.runner.setContextWindowSize(ctxSize);
|
|
35065
|
+
}
|
|
35015
35066
|
}
|
|
35016
35067
|
}).catch(() => {
|
|
35017
35068
|
});
|
package/package.json
CHANGED