open-agents-ai 0.187.354 → 0.187.356
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
CHANGED
|
@@ -270030,6 +270030,10 @@ var init_agenticRunner = __esm({
|
|
|
270030
270030
|
// sliding window of last 8 tool calls
|
|
270031
270031
|
_microcompactHintEmitted = false;
|
|
270032
270032
|
// WO-LL-02: one memory hint per session
|
|
270033
|
+
/** Timestamp of last assistant message — for idle-time microcompaction (Qwen pattern) */
|
|
270034
|
+
_lastAssistantTimestamp = Date.now();
|
|
270035
|
+
/** Track thinking block accumulation — strips after idle (Qwen thinkingClearLatched) */
|
|
270036
|
+
_thinkingClearLatched = false;
|
|
270033
270037
|
_hookDenyHintCount = 0;
|
|
270034
270038
|
// WO-LL-02: cap hint injection at 3 per session
|
|
270035
270039
|
_selfConsistencyVotes = 0;
|
|
@@ -270535,7 +270539,12 @@ ${body}`;
|
|
|
270535
270539
|
*/
|
|
270536
270540
|
microcompact(messages2, recentToolResults) {
|
|
270537
270541
|
const tier = this.options.modelTier ?? "large";
|
|
270538
|
-
|
|
270542
|
+
let keepResults = tier === "small" ? 6 : tier === "medium" ? 10 : 20;
|
|
270543
|
+
const idleGapMs = Date.now() - this._lastAssistantTimestamp;
|
|
270544
|
+
const IDLE_THRESHOLD_MS = 5 * 6e4;
|
|
270545
|
+
if (idleGapMs > IDLE_THRESHOLD_MS) {
|
|
270546
|
+
keepResults = Math.min(keepResults, 3);
|
|
270547
|
+
}
|
|
270539
270548
|
const toolResultIndices = [];
|
|
270540
270549
|
for (let i2 = 0; i2 < messages2.length; i2++) {
|
|
270541
270550
|
if (messages2[i2].role === "tool") {
|
|
@@ -270558,6 +270567,27 @@ ${body}`;
|
|
|
270558
270567
|
};
|
|
270559
270568
|
cleared++;
|
|
270560
270569
|
}
|
|
270570
|
+
if (idleGapMs > IDLE_THRESHOLD_MS && !this._thinkingClearLatched) {
|
|
270571
|
+
this._thinkingClearLatched = true;
|
|
270572
|
+
let thinkStripped = 0;
|
|
270573
|
+
for (let i2 = 0; i2 < messages2.length - keepResults; i2++) {
|
|
270574
|
+
const msg = messages2[i2];
|
|
270575
|
+
if (msg.role === "assistant" && typeof msg.content === "string" && msg.content.length > 200) {
|
|
270576
|
+
const stripped = msg.content.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<reasoning>[\s\S]*?<\/reasoning>/gi, "").replace(/\[THINKING\][\s\S]*?\[\/THINKING\]/gi, "").trim();
|
|
270577
|
+
if (stripped.length < msg.content.length * 0.8) {
|
|
270578
|
+
messages2[i2] = { ...msg, content: stripped || "[thinking stripped]" };
|
|
270579
|
+
thinkStripped++;
|
|
270580
|
+
}
|
|
270581
|
+
}
|
|
270582
|
+
}
|
|
270583
|
+
if (thinkStripped > 0) {
|
|
270584
|
+
this.emit({
|
|
270585
|
+
type: "status",
|
|
270586
|
+
content: `Idle thinking strip: cleared thinking blocks from ${thinkStripped} old assistant message(s)`,
|
|
270587
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
270588
|
+
});
|
|
270589
|
+
}
|
|
270590
|
+
}
|
|
270561
270591
|
if (cleared > 0) {
|
|
270562
270592
|
if (recentToolResults) {
|
|
270563
270593
|
for (const entry of recentToolResults.values())
|
|
@@ -271332,6 +271362,7 @@ ${memoryLines.join("\n")}`
|
|
|
271332
271362
|
} catch {
|
|
271333
271363
|
}
|
|
271334
271364
|
}
|
|
271365
|
+
this._lastAssistantTimestamp = Date.now();
|
|
271335
271366
|
this.microcompact(compacted, recentToolResults);
|
|
271336
271367
|
const { maxOutputTokens: effectiveMaxTokens } = this.contextLimits();
|
|
271337
271368
|
const chatRequest = {
|
|
@@ -273167,10 +273198,15 @@ ${errOutput}`;
|
|
|
273167
273198
|
${result.output}`, "utf-8");
|
|
273168
273199
|
} catch {
|
|
273169
273200
|
}
|
|
273170
|
-
|
|
273171
|
-
|
|
273172
|
-
|
|
273173
|
-
|
|
273201
|
+
const { join: _pj } = __require("node:path");
|
|
273202
|
+
const savedPath = _pj(process.cwd(), ".oa", "tool-results", `${handleId}.txt`);
|
|
273203
|
+
const folded = this.foldOutput(result.output, maxLen);
|
|
273204
|
+
return `[Tool output truncated — ${result.output.length} chars, ${lineCount} lines]
|
|
273205
|
+
Full output saved to: ${savedPath}
|
|
273206
|
+
To read the complete output, use file_read with path="${savedPath}".
|
|
273207
|
+
|
|
273208
|
+
Truncated preview (beginning + end):
|
|
273209
|
+
${folded}`;
|
|
273174
273210
|
}
|
|
273175
273211
|
/**
|
|
273176
273212
|
* WO-INF-02: Build structured error recovery guidance for small/medium models.
|
package/package.json
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
|
-
You are
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
You are the component that summarizes internal chat history into a structured snapshot.
|
|
2
|
+
|
|
3
|
+
When the conversation history grows too large, you will be invoked to distill the entire history into a concise, structured XML snapshot. This snapshot is CRITICAL — it will become the agent's ONLY memory of the past. The agent will resume its work based solely on this snapshot. All crucial details, plans, errors, and user directives MUST be preserved.
|
|
4
|
+
|
|
5
|
+
First, review the user's overall goal, the agent's actions, tool outputs, file modifications, and any unresolved questions. Identify every piece of information essential for future actions.
|
|
6
|
+
|
|
7
|
+
Then generate the final snapshot. Be incredibly dense with information. Omit conversational filler.
|
|
8
|
+
|
|
9
|
+
The structure MUST be as follows:
|
|
10
|
+
|
|
11
|
+
<state_snapshot>
|
|
12
|
+
<overall_goal>
|
|
13
|
+
<!-- A single, concise sentence describing the user's high-level objective. -->
|
|
14
|
+
</overall_goal>
|
|
15
|
+
|
|
16
|
+
<key_knowledge>
|
|
17
|
+
<!-- Crucial facts, conventions, and constraints the agent must remember. Use bullet points. -->
|
|
18
|
+
<!-- Include: file paths, commands, tool names, patterns discovered, user preferences -->
|
|
19
|
+
</key_knowledge>
|
|
20
|
+
|
|
21
|
+
<file_system_state>
|
|
22
|
+
<!-- List files created, read, modified, or deleted. Note status and critical learnings. -->
|
|
23
|
+
<!-- Format: - CWD: /path - READ: file.ts - purpose - MODIFIED: file.ts - what changed -->
|
|
24
|
+
</file_system_state>
|
|
25
|
+
|
|
26
|
+
<recent_actions>
|
|
27
|
+
<!-- Summary of the last significant agent actions and their outcomes. Focus on facts. -->
|
|
28
|
+
<!-- Include tool names, arguments, and whether they succeeded or failed. -->
|
|
29
|
+
</recent_actions>
|
|
30
|
+
|
|
31
|
+
<errors_and_fixes>
|
|
32
|
+
<!-- Any errors encountered, their root causes, and how they were resolved. -->
|
|
33
|
+
<!-- Preserve error messages verbatim where possible. -->
|
|
34
|
+
</errors_and_fixes>
|
|
35
|
+
|
|
36
|
+
<current_plan>
|
|
37
|
+
<!-- The agent's step-by-step plan. Mark completed steps. -->
|
|
38
|
+
<!-- Format: 1. [DONE] Step description 2. [IN PROGRESS] Step 3. [TODO] Step -->
|
|
39
|
+
</current_plan>
|
|
40
|
+
|
|
41
|
+
<failed_approaches>
|
|
42
|
+
<!-- Approaches that were tried and failed. The agent must NOT repeat these. -->
|
|
43
|
+
</failed_approaches>
|
|
44
|
+
</state_snapshot>
|