open-agents-ai 0.187.25 → 0.187.27

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.
Files changed (2) hide show
  1. package/dist/index.js +81 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -260114,6 +260114,8 @@ var init_agenticRunner = __esm({
260114
260114
  // WO-LL-02: one memory hint per session
260115
260115
  _hookDenyHintCount = 0;
260116
260116
  // WO-LL-02: cap hint injection at 3 per session
260117
+ _selfConsistencyVotes = 0;
260118
+ // WO-INF-01: cap voting events at 2 per run
260117
260119
  _loopBlockedTools;
260118
260120
  // Loop intervention: tools removed from schema
260119
260121
  // -- Session Checkpointing (Priority 5) --
@@ -260309,7 +260311,8 @@ ${body}`;
260309
260311
  const deep = this.options.deepContext ?? false;
260310
260312
  let compactionThreshold;
260311
260313
  if (ctx3 > 0) {
260312
- const factor = deep ? 0.85 : tier === "small" ? 0.65 : tier === "medium" ? 0.7 : 0.75;
260314
+ const userPercent = this.options.compactionPercent;
260315
+ const factor = userPercent != null ? userPercent / 100 : deep ? 0.85 : tier === "small" ? 0.65 : tier === "medium" ? 0.7 : 0.75;
260313
260316
  compactionThreshold = Math.floor(ctx3 * factor);
260314
260317
  } else {
260315
260318
  compactionThreshold = deep ? 8e4 : this.options.compactionThreshold;
@@ -260654,6 +260657,7 @@ TASK: ${task}` : task;
260654
260657
  this._assistantTextEmitted = false;
260655
260658
  this._microcompactHintEmitted = false;
260656
260659
  this._hookDenyHintCount = 0;
260660
+ this._selfConsistencyVotes = 0;
260657
260661
  this._loopBlockedTools = void 0;
260658
260662
  let pendingConstraintWarnings = [];
260659
260663
  let consecutiveTextOnly = 0;
@@ -261019,6 +261023,58 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
261019
261023
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
261020
261024
  tokenUsage: { promptTokens, completionTokens, totalTokens, estimatedContextTokens }
261021
261025
  });
261026
+ {
261027
+ const { compactionThreshold: ctxThreshold } = this.contextLimits();
261028
+ const utilPct = ctxThreshold > 0 ? Math.round(estimatedContextTokens / ctxThreshold * 100) : 0;
261029
+ if (utilPct > 50) {
261030
+ this.emit({
261031
+ type: "status",
261032
+ content: `Context: ~${estimatedContextTokens}t / ${ctxThreshold}t (${utilPct}%)${utilPct > 85 ? " \u26A0\uFE0F compaction imminent" : ""}`,
261033
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
261034
+ });
261035
+ }
261036
+ }
261037
+ const firstToolCall = response.choices[0]?.message?.toolCalls?.[0];
261038
+ const HIGH_STAKE_TOOLS = /* @__PURE__ */ new Set(["file_write", "file_edit", "batch_edit", "file_patch", "shell"]);
261039
+ const selfConsistencyK = this.options.selfConsistencyK ?? 0;
261040
+ const shouldVote = selfConsistencyK >= 2 && this._selfConsistencyVotes < 2 && (this.options.modelTier === "small" || this.options.modelTier === "medium") && firstToolCall && HIGH_STAKE_TOOLS.has(firstToolCall.name) && turn <= 3;
261041
+ if (shouldVote && firstToolCall) {
261042
+ try {
261043
+ const alternatives = await Promise.allSettled([
261044
+ this.backend.chatCompletion({ ...chatRequest, temperature: 0.7 }),
261045
+ this.backend.chatCompletion({ ...chatRequest, temperature: 0.7 })
261046
+ ]);
261047
+ const candidates = [response];
261048
+ for (const alt of alternatives) {
261049
+ if (alt.status === "fulfilled")
261050
+ candidates.push(alt.value);
261051
+ }
261052
+ const votes = candidates.map((c4) => {
261053
+ const tc = c4.choices[0]?.message?.toolCalls?.[0];
261054
+ if (!tc)
261055
+ return "none";
261056
+ const argPreview = JSON.stringify(tc.arguments).slice(0, 150);
261057
+ return `${tc.name}:${argPreview}`;
261058
+ });
261059
+ const counts = /* @__PURE__ */ new Map();
261060
+ for (const v of votes)
261061
+ counts.set(v, (counts.get(v) ?? 0) + 1);
261062
+ const [majorityKey, majorityCount] = [...counts.entries()].sort((a2, b) => b[1] - a2[1])[0];
261063
+ if (majorityCount > 1 && majorityKey !== votes[0]) {
261064
+ const idx = votes.indexOf(majorityKey);
261065
+ if (idx > 0) {
261066
+ response = candidates[idx];
261067
+ this.emit({
261068
+ type: "status",
261069
+ content: `Self-consistency: voted ${majorityCount}/${candidates.length} for alternative (switched)`,
261070
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
261071
+ });
261072
+ }
261073
+ }
261074
+ this._selfConsistencyVotes++;
261075
+ } catch {
261076
+ }
261077
+ }
261022
261078
  const choice = response.choices[0];
261023
261079
  if (!choice)
261024
261080
  break;
@@ -262356,6 +262412,18 @@ ${taskStateStr}
262356
262412
  if (memexIndexStr)
262357
262413
  enrichments.push(memexIndexStr);
262358
262414
  }
262415
+ const postCompactRestore = [];
262416
+ const planSkel = this.buildPlanSkeleton();
262417
+ if (planSkel)
262418
+ postCompactRestore.push(planSkel.trim());
262419
+ const mcpToolNames = [...this.tools.keys()].filter((n2) => n2.startsWith("mcp_") || n2.startsWith("mcp__"));
262420
+ if (mcpToolNames.length > 0) {
262421
+ postCompactRestore.push(`Available MCP tools: ${mcpToolNames.join(", ")}`);
262422
+ }
262423
+ if (postCompactRestore.length > 0) {
262424
+ enrichments.push(`[Post-compaction context restore]
262425
+ ${postCompactRestore.join("\n")}`);
262426
+ }
262359
262427
  const fullSummary = enrichments.join("\n\n");
262360
262428
  const goalReminder = this._taskState.goal ? `
262361
262429
 
@@ -306373,6 +306441,15 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
306373
306441
  } else {
306374
306442
  backend = new OllamaAgenticBackend(config.backendUrl, config.model, config.apiKey);
306375
306443
  }
306444
+ const parentDepth = args["_recursionDepth"] ?? 0;
306445
+ const maxDepth = 3;
306446
+ if (parentDepth >= maxDepth) {
306447
+ return {
306448
+ success: false,
306449
+ output: "",
306450
+ error: `Maximum recursion depth (${maxDepth}) reached. Solve this sub-task directly without further delegation.`
306451
+ };
306452
+ }
306376
306453
  const subCtxWindow = ctxWindowSize ?? 0;
306377
306454
  const subTier = getModelTier(config.model);
306378
306455
  const subCompaction = subTier === "small" ? 12e3 : subTier === "medium" ? 24e3 : 4e4;
@@ -306384,7 +306461,9 @@ function createSubAgentTool(config, repoRoot, ctxWindowSize) {
306384
306461
  taskTimeoutMs: config.timeoutMs * 2,
306385
306462
  compactionThreshold: subCompaction,
306386
306463
  contextWindowSize: subCtxWindow,
306387
- modelTier: subTier
306464
+ modelTier: subTier,
306465
+ recursionDepth: parentDepth + 1,
306466
+ maxRecursionDepth: maxDepth
306388
306467
  });
306389
306468
  const subTools = [
306390
306469
  new FileReadTool(repoRoot),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.25",
3
+ "version": "0.187.27",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",