open-agents-ai 0.187.353 → 0.187.355
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 +42 -21
- package/package.json +1 -1
- package/prompts/compaction/context-compaction.md +44 -9
package/dist/index.js
CHANGED
|
@@ -270535,7 +270535,21 @@ ${body}`;
|
|
|
270535
270535
|
*/
|
|
270536
270536
|
microcompact(messages2, recentToolResults) {
|
|
270537
270537
|
const tier = this.options.modelTier ?? "large";
|
|
270538
|
-
|
|
270538
|
+
let keepResults = tier === "small" ? 6 : tier === "medium" ? 10 : 20;
|
|
270539
|
+
let lastAssistant;
|
|
270540
|
+
for (let i2 = messages2.length - 1; i2 >= 0; i2--) {
|
|
270541
|
+
if (messages2[i2].role === "assistant") {
|
|
270542
|
+
lastAssistant = messages2[i2];
|
|
270543
|
+
break;
|
|
270544
|
+
}
|
|
270545
|
+
}
|
|
270546
|
+
if (lastAssistant && typeof lastAssistant._timestamp === "number") {
|
|
270547
|
+
const gapMs = Date.now() - lastAssistant._timestamp;
|
|
270548
|
+
const IDLE_THRESHOLD_MS = 5 * 6e4;
|
|
270549
|
+
if (gapMs > IDLE_THRESHOLD_MS) {
|
|
270550
|
+
keepResults = Math.min(keepResults, 3);
|
|
270551
|
+
}
|
|
270552
|
+
}
|
|
270539
270553
|
const toolResultIndices = [];
|
|
270540
270554
|
for (let i2 = 0; i2 < messages2.length; i2++) {
|
|
270541
270555
|
if (messages2[i2].role === "tool") {
|
|
@@ -273167,10 +273181,15 @@ ${errOutput}`;
|
|
|
273167
273181
|
${result.output}`, "utf-8");
|
|
273168
273182
|
} catch {
|
|
273169
273183
|
}
|
|
273170
|
-
|
|
273171
|
-
|
|
273172
|
-
|
|
273173
|
-
|
|
273184
|
+
const { join: _pj } = __require("node:path");
|
|
273185
|
+
const savedPath = _pj(process.cwd(), ".oa", "tool-results", `${handleId}.txt`);
|
|
273186
|
+
const folded = this.foldOutput(result.output, maxLen);
|
|
273187
|
+
return `[Tool output truncated — ${result.output.length} chars, ${lineCount} lines]
|
|
273188
|
+
Full output saved to: ${savedPath}
|
|
273189
|
+
To read the complete output, use file_read with path="${savedPath}".
|
|
273190
|
+
|
|
273191
|
+
Truncated preview (beginning + end):
|
|
273192
|
+
${folded}`;
|
|
273174
273193
|
}
|
|
273175
273194
|
/**
|
|
273176
273195
|
* WO-INF-02: Build structured error recovery guidance for small/medium models.
|
|
@@ -332807,28 +332826,30 @@ ${lines.join("\n")}
|
|
|
332807
332826
|
dynamicContext += `
|
|
332808
332827
|
|
|
332809
332828
|
<vision-capabilities>
|
|
332810
|
-
You have vision capabilities
|
|
332829
|
+
You have vision capabilities. Choose the RIGHT tool for each situation:
|
|
332811
332830
|
|
|
332812
|
-
IMAGE
|
|
332813
|
-
image_read(image="path") —
|
|
332814
|
-
vision(image="path", action="caption") — Describe image contents
|
|
332815
|
-
vision(image="path", action="query", prompt="question") —
|
|
332831
|
+
FOR IMAGE FILES (photos, screenshots, diagrams):
|
|
332832
|
+
image_read(image="path") — Read an image file (base64 + OCR)
|
|
332833
|
+
vision(image="path", action="caption") — Describe image contents via Moondream
|
|
332834
|
+
vision(image="path", action="query", prompt="question") — Ask questions about an image
|
|
332816
332835
|
vision(image="path", action="detect", prompt="object") — Find objects (bounding boxes)
|
|
332817
|
-
vision(image="path", action="point", prompt="element") — Find element center (for clicking)
|
|
332818
332836
|
|
|
332819
|
-
|
|
332820
|
-
|
|
332821
|
-
|
|
332822
|
-
|
|
332823
|
-
|
|
332824
|
-
|
|
332837
|
+
FOR CAMERA (webcam, USB camera):
|
|
332838
|
+
camera_capture() — Take a photo from the webcam
|
|
332839
|
+
|
|
332840
|
+
FOR SCREENSHOTS (what's on screen right now):
|
|
332841
|
+
screenshot() — Take a screenshot of the desktop
|
|
332842
|
+
|
|
332843
|
+
FOR DESKTOP UI INTERACTION (clicking, navigating):
|
|
332844
|
+
desktop_describe() — Screenshot + describe UI elements on screen
|
|
332845
|
+
desktop_click({ target: "element" }) — Click a UI element by description
|
|
332825
332846
|
|
|
332826
332847
|
RULES:
|
|
332827
332848
|
- Do NOT say you cannot see images — you can.
|
|
332828
|
-
-
|
|
332829
|
-
-
|
|
332830
|
-
- For
|
|
332831
|
-
-
|
|
332849
|
+
- For reading an image FILE → use image_read or vision, NOT desktop_describe.
|
|
332850
|
+
- For taking a PHOTO → use camera_capture, NOT desktop_describe.
|
|
332851
|
+
- For seeing the SCREEN → use screenshot or desktop_describe.
|
|
332852
|
+
- Only use desktop_describe + desktop_click for UI automation tasks.
|
|
332832
332853
|
</vision-capabilities>`;
|
|
332833
332854
|
}
|
|
332834
332855
|
let localFirstOverride = false;
|
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>
|