open-agents-ai 0.187.154 → 0.187.155
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 +108 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -264709,6 +264709,19 @@ var init_agenticRunner = __esm({
|
|
|
264709
264709
|
// WO-KG-15
|
|
264710
264710
|
_retrievalContextCache = null;
|
|
264711
264711
|
// WO-KG-15: cache per-run
|
|
264712
|
+
// ── WO-NC-07: Error pattern learning → pre-action guidance injection ──
|
|
264713
|
+
// Records error patterns (tool + error signature → learned guidance).
|
|
264714
|
+
// When the same tool+context is about to be called again, injects the
|
|
264715
|
+
// learned guidance BEFORE execution to prevent repeating the same mistake.
|
|
264716
|
+
//
|
|
264717
|
+
// Structure: Map<errorSignature, { count, guidance, lastSeen }>
|
|
264718
|
+
// errorSignature = `${toolName}:${errorType}` (e.g. "file_read:ENOENT", "shell:permission_denied")
|
|
264719
|
+
//
|
|
264720
|
+
// Research: Kumaran et al. (2016) — complementary learning systems
|
|
264721
|
+
// Fast learning from errors → immediate behavioral change
|
|
264722
|
+
_errorPatterns = /* @__PURE__ */ new Map();
|
|
264723
|
+
_errorGuidanceInjected = /* @__PURE__ */ new Set();
|
|
264724
|
+
// prevent duplicate injection per turn
|
|
264712
264725
|
_loopBlockedTools;
|
|
264713
264726
|
// Loop intervention: tools removed from schema
|
|
264714
264727
|
// -- Session Checkpointing (Priority 5) --
|
|
@@ -265234,6 +265247,18 @@ Respond with your assessment, then take action.`;
|
|
|
265234
265247
|
const toolCallLog = [];
|
|
265235
265248
|
this.aborted = false;
|
|
265236
265249
|
this._paused = false;
|
|
265250
|
+
try {
|
|
265251
|
+
const fs4 = await import("node:fs");
|
|
265252
|
+
const path5 = await import("node:path");
|
|
265253
|
+
const patternsFile = path5.join(process.cwd(), ".oa", "error-patterns.json");
|
|
265254
|
+
if (fs4.existsSync(patternsFile)) {
|
|
265255
|
+
const saved = JSON.parse(fs4.readFileSync(patternsFile, "utf8"));
|
|
265256
|
+
for (const [sig, pattern] of Object.entries(saved)) {
|
|
265257
|
+
this._errorPatterns.set(sig, pattern);
|
|
265258
|
+
}
|
|
265259
|
+
}
|
|
265260
|
+
} catch {
|
|
265261
|
+
}
|
|
265237
265262
|
this._pauseResolve = null;
|
|
265238
265263
|
this.pendingUserMessages.length = 0;
|
|
265239
265264
|
this._taskState = {
|
|
@@ -265803,6 +265828,14 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
265803
265828
|
const executeSingle = async (tc) => {
|
|
265804
265829
|
if (this.aborted)
|
|
265805
265830
|
return null;
|
|
265831
|
+
if (this._errorPatterns.size > 0) {
|
|
265832
|
+
for (const [sig, pattern] of this._errorPatterns) {
|
|
265833
|
+
if (pattern.tool === tc.name && pattern.count >= 2 && !this._errorGuidanceInjected.has(sig)) {
|
|
265834
|
+
this._errorGuidanceInjected.add(sig);
|
|
265835
|
+
this.pendingUserMessages.push(`[LEARNED FROM EXPERIENCE] ${tc.name} has failed ${pattern.count} times with "${pattern.errorType}" errors. Guidance: ${pattern.guidance}`);
|
|
265836
|
+
}
|
|
265837
|
+
}
|
|
265838
|
+
}
|
|
265806
265839
|
const toolStart = performance.now();
|
|
265807
265840
|
toolCallCount++;
|
|
265808
265841
|
const argsKey = Object.entries(tc.arguments ?? {}).sort(([a2], [b]) => a2.localeCompare(b)).map(([k, v]) => `${k}=${typeof v === "string" ? v.slice(0, 80) : JSON.stringify(v)}`).join(",");
|
|
@@ -265967,6 +266000,58 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
265967
266000
|
}
|
|
265968
266001
|
}
|
|
265969
266002
|
}
|
|
266003
|
+
if (!result.success && result.error) {
|
|
266004
|
+
const errorText = result.error;
|
|
266005
|
+
let errorType = "unknown";
|
|
266006
|
+
if (/not found|ENOENT|no such file/i.test(errorText))
|
|
266007
|
+
errorType = "not_found";
|
|
266008
|
+
else if (/permission|denied|EACCES/i.test(errorText))
|
|
266009
|
+
errorType = "permission";
|
|
266010
|
+
else if (/timeout|timed out|ETIMEDOUT/i.test(errorText))
|
|
266011
|
+
errorType = "timeout";
|
|
266012
|
+
else if (/busy|EBUSY|in use/i.test(errorText))
|
|
266013
|
+
errorType = "busy";
|
|
266014
|
+
else if (/syntax|parse|invalid/i.test(errorText))
|
|
266015
|
+
errorType = "syntax";
|
|
266016
|
+
else if (/connect|ECONNREFUSED|network/i.test(errorText))
|
|
266017
|
+
errorType = "network";
|
|
266018
|
+
const sig = `${tc.name}:${errorType}`;
|
|
266019
|
+
const existing = this._errorPatterns.get(sig);
|
|
266020
|
+
const count = (existing?.count ?? 0) + 1;
|
|
266021
|
+
let guidance = "";
|
|
266022
|
+
switch (errorType) {
|
|
266023
|
+
case "not_found":
|
|
266024
|
+
guidance = `File/resource not found. Before retrying: use list_directory or find_files to verify the path exists. Common causes: wrong directory, typo in filename, file was moved/renamed.`;
|
|
266025
|
+
break;
|
|
266026
|
+
case "permission":
|
|
266027
|
+
guidance = `Permission denied. The command may need sudo/elevated privileges. Use shell with sudo, or check file ownership with 'ls -la'.`;
|
|
266028
|
+
break;
|
|
266029
|
+
case "timeout":
|
|
266030
|
+
guidance = `Operation timed out. The target may be unreachable or overloaded. Try: shorter timeout, different endpoint, or verify network connectivity first.`;
|
|
266031
|
+
break;
|
|
266032
|
+
case "busy":
|
|
266033
|
+
guidance = `Resource is busy/locked. Another process may be using it. Check with 'lsof' or 'fuser', or wait and retry.`;
|
|
266034
|
+
break;
|
|
266035
|
+
case "syntax":
|
|
266036
|
+
guidance = `Syntax/parse error. Review the command or input for typos, missing quotes, or incorrect parameter format.`;
|
|
266037
|
+
break;
|
|
266038
|
+
case "network":
|
|
266039
|
+
guidance = `Network error. Check connectivity: ping the target, verify the URL/host is correct, check if a proxy is needed.`;
|
|
266040
|
+
break;
|
|
266041
|
+
default:
|
|
266042
|
+
guidance = `This tool failed previously with a similar error. Review the error message carefully and adjust your approach before retrying.`;
|
|
266043
|
+
}
|
|
266044
|
+
this._errorPatterns.set(sig, { count, guidance, lastSeen: Date.now(), tool: tc.name, errorType });
|
|
266045
|
+
const lastLog = toolCallLog[toolCallLog.length - 1];
|
|
266046
|
+
if (lastLog) {
|
|
266047
|
+
lastLog.success = false;
|
|
266048
|
+
lastLog.outputPreview = errorText.slice(0, 100);
|
|
266049
|
+
}
|
|
266050
|
+
} else if (result.success) {
|
|
266051
|
+
const lastLog = toolCallLog[toolCallLog.length - 1];
|
|
266052
|
+
if (lastLog)
|
|
266053
|
+
lastLog.success = true;
|
|
266054
|
+
}
|
|
265970
266055
|
if (isReadLike && result.success) {
|
|
265971
266056
|
recentToolResults.set(toolFingerprint, (result.output ?? "").slice(0, 2e3));
|
|
265972
266057
|
if (recentToolResults.size > 50) {
|
|
@@ -266640,6 +266725,29 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
266640
266725
|
success: completed,
|
|
266641
266726
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
266642
266727
|
});
|
|
266728
|
+
if (this._errorPatterns.size > 0) {
|
|
266729
|
+
try {
|
|
266730
|
+
const fs4 = await import("node:fs");
|
|
266731
|
+
const path5 = await import("node:path");
|
|
266732
|
+
const patternsFile = path5.join(process.cwd(), ".oa", "error-patterns.json");
|
|
266733
|
+
fs4.mkdirSync(path5.join(process.cwd(), ".oa"), { recursive: true });
|
|
266734
|
+
let existing = {};
|
|
266735
|
+
try {
|
|
266736
|
+
existing = JSON.parse(fs4.readFileSync(patternsFile, "utf8"));
|
|
266737
|
+
} catch {
|
|
266738
|
+
}
|
|
266739
|
+
for (const [sig, pattern] of this._errorPatterns) {
|
|
266740
|
+
const prev = existing[sig];
|
|
266741
|
+
existing[sig] = {
|
|
266742
|
+
...pattern,
|
|
266743
|
+
count: (prev?.count ?? 0) + pattern.count,
|
|
266744
|
+
firstSeen: prev?.firstSeen ?? pattern.lastSeen
|
|
266745
|
+
};
|
|
266746
|
+
}
|
|
266747
|
+
fs4.writeFileSync(patternsFile, JSON.stringify(existing, null, 2));
|
|
266748
|
+
} catch {
|
|
266749
|
+
}
|
|
266750
|
+
}
|
|
266643
266751
|
try {
|
|
266644
266752
|
const extractPaths = (entries, toolNames) => {
|
|
266645
266753
|
return [...new Set(entries.filter((tc) => toolNames.includes(tc.name)).map((tc) => {
|
package/package.json
CHANGED