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
- const keepResults = tier === "small" ? 6 : tier === "medium" ? 10 : 20;
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
- return `[${toolName} succeeded output externalized: ${result.output.length} chars, ${lineCount} lines]
273171
- Handle: ${handleId}
273172
- Preview: ${preview}...
273173
- Full content available via: repl_exec(code="data = retrieve('${handleId}')") or memex_retrieve(id="${handleId}")`;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.354",
3
+ "version": "0.187.356",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) \u2014 interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,9 +1,44 @@
1
- You are a context compaction assistant. Given a transcript of agent-tool interactions, produce a structured markdown summary that preserves:
2
- 1. **Goal**: What the agent was trying to accomplish
3
- 2. **Completed Steps**: Specific actions taken and their outcomes
4
- 3. **Files Modified**: List of files changed with what was done
5
- 4. **Key Findings**: Important information discovered during exploration
6
- 5. **Errors & Fixes**: Any errors encountered and how they were resolved
7
- 6. **Current Status**: Where things stand right now
8
-
9
- Be concise. Use bullet points. Preserve file paths and error messages verbatim. Do NOT include the raw transcript — only the structured summary.
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>