open-agents-ai 0.186.6 → 0.186.8
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/README.md +61 -0
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1072,6 +1072,67 @@ The identity kernel maintains a persistent self-model across sessions, the refle
|
|
|
1072
1072
|
| L8 | Darwin Gödel Machine: Open-Ended Self-Improvement (2025) | [arxiv:2505.22954](https://arxiv.org/abs/2505.22954) |
|
|
1073
1073
|
| L8 | i-MENTOR: Intrinsic Motivation Exploration (2025) | [arxiv:2505.17621](https://arxiv.org/abs/2505.17621) |
|
|
1074
1074
|
|
|
1075
|
+
## Agent Immune System — Constraint Enforcement & Pressure Resistance
|
|
1076
|
+
|
|
1077
|
+
<div align="right"><a href="#top">back to top</a></div>
|
|
1078
|
+
|
|
1079
|
+
Open Agents includes a behavioral immune system that prevents the agent from making pattern-matched mistakes under pressure. Inspired by biological immune systems: constraints are the antibodies, pressure detection is the inflammatory response, and memory injection is the recall mechanism.
|
|
1080
|
+
|
|
1081
|
+
### Constraint Enforcement (`.oa/constraints.json`)
|
|
1082
|
+
|
|
1083
|
+
Machine-readable rules checked **before every tool execution**:
|
|
1084
|
+
|
|
1085
|
+
```json
|
|
1086
|
+
{
|
|
1087
|
+
"constraints": [
|
|
1088
|
+
{
|
|
1089
|
+
"id": "no-reward-hack",
|
|
1090
|
+
"trigger": "file_write|file_edit",
|
|
1091
|
+
"pattern": "NEVER say|ALWAYS say",
|
|
1092
|
+
"target_files": ["prompts/**/*.md"],
|
|
1093
|
+
"action": "warn",
|
|
1094
|
+
"message": "This looks like a reward-hacking directive. Fix the architecture, not the prompt."
|
|
1095
|
+
}
|
|
1096
|
+
]
|
|
1097
|
+
}
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
| Action | Behavior |
|
|
1101
|
+
|--------|----------|
|
|
1102
|
+
| `block` | Prevents tool execution entirely, returns error to model |
|
|
1103
|
+
| `warn` | Executes tool but emits warning in agent's next turn context |
|
|
1104
|
+
| `log` | Silent recording to audit log, no interruption |
|
|
1105
|
+
|
|
1106
|
+
Constraints are scoped: global (`~/.open-agents/constraints.json`), project (`.oa/constraints.json`), or session (ephemeral).
|
|
1107
|
+
|
|
1108
|
+
### Pressure-Aware Decision Gate
|
|
1109
|
+
|
|
1110
|
+
When the user is frustrated (detected via keyword matching), a brief `<reflection>` cue is injected into the agent's system prompt for ONE turn:
|
|
1111
|
+
|
|
1112
|
+
```
|
|
1113
|
+
<reflection>The user is very frustrated. Pause. Check your constraints
|
|
1114
|
+
and past feedback before writing code. The fastest fix is often the wrong fix.</reflection>
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
This is NOT a block — it's a speed bump that prompts deliberation when the agent is most likely to cut corners. Zero overhead when no pressure is detected.
|
|
1118
|
+
|
|
1119
|
+
| Pressure Level | Detection | Response |
|
|
1120
|
+
|---------------|-----------|----------|
|
|
1121
|
+
| **none** | Normal messages | No cue (zero tokens) |
|
|
1122
|
+
| **moderate** | Frustration signals | "Verify your change addresses the root cause" |
|
|
1123
|
+
| **high** | Strong frustration + urgency | "Pause. Check constraints before acting" |
|
|
1124
|
+
|
|
1125
|
+
### How It Works Together
|
|
1126
|
+
|
|
1127
|
+
```
|
|
1128
|
+
User (frustrated): "fix this broken shit"
|
|
1129
|
+
→ Pressure gate detects "high" → injects reflection cue
|
|
1130
|
+
→ Model proposes file_edit on prompts/system.md with "NEVER say..."
|
|
1131
|
+
→ Constraint checker matches "no-reward-hack" → emits warning
|
|
1132
|
+
→ Model sees warning on next turn → reconsiders approach
|
|
1133
|
+
→ Model fixes the architecture instead of adding a prompt hack
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1075
1136
|
## Context Compaction — Research-Backed Memory Management
|
|
1076
1137
|
|
|
1077
1138
|
<div align="right"><a href="#top">back to top</a></div>
|
package/dist/index.js
CHANGED
|
@@ -26341,6 +26341,7 @@ TASK: ${task}` : task;
|
|
|
26341
26341
|
let summary = "";
|
|
26342
26342
|
let bruteForceCycle = 0;
|
|
26343
26343
|
this._assistantTextEmitted = false;
|
|
26344
|
+
let pendingConstraintWarnings = [];
|
|
26344
26345
|
let consecutiveTextOnly = 0;
|
|
26345
26346
|
const MAX_CONSECUTIVE_TEXT_ONLY = 3;
|
|
26346
26347
|
let narratedToolCallCount = 0;
|
|
@@ -26358,6 +26359,11 @@ TASK: ${task}` : task;
|
|
|
26358
26359
|
this.emit({ type: "error", content: "Task aborted by user", timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
26359
26360
|
break;
|
|
26360
26361
|
}
|
|
26362
|
+
if (pendingConstraintWarnings.length > 0) {
|
|
26363
|
+
const warningMsg = "<constraint-recall>\n" + pendingConstraintWarnings.join("\n") + "\n</constraint-recall>";
|
|
26364
|
+
messages.push({ role: "system", content: warningMsg });
|
|
26365
|
+
pendingConstraintWarnings = [];
|
|
26366
|
+
}
|
|
26361
26367
|
const now = Date.now();
|
|
26362
26368
|
if (now > nextSelfEval) {
|
|
26363
26369
|
selfEvalCount++;
|
|
@@ -26816,7 +26822,9 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
26816
26822
|
} else {
|
|
26817
26823
|
const warnViolations = violations.filter((v) => v.constraint.action === "warn");
|
|
26818
26824
|
if (warnViolations.length > 0) {
|
|
26819
|
-
|
|
26825
|
+
const warning = formatViolationWarning(warnViolations);
|
|
26826
|
+
this.emit({ type: "status", content: `\u26A0\uFE0F ${warning}`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
26827
|
+
pendingConstraintWarnings.push(warning);
|
|
26820
26828
|
}
|
|
26821
26829
|
try {
|
|
26822
26830
|
result = await tool.execute(tc.arguments);
|
|
@@ -29313,6 +29321,13 @@ ${description}`
|
|
|
29313
29321
|
}
|
|
29314
29322
|
});
|
|
29315
29323
|
|
|
29324
|
+
// packages/orchestrator/dist/constraint-learner.js
|
|
29325
|
+
var init_constraint_learner = __esm({
|
|
29326
|
+
"packages/orchestrator/dist/constraint-learner.js"() {
|
|
29327
|
+
"use strict";
|
|
29328
|
+
}
|
|
29329
|
+
});
|
|
29330
|
+
|
|
29316
29331
|
// packages/orchestrator/dist/nexusBackend.js
|
|
29317
29332
|
import { existsSync as existsSync32, statSync as statSync10, openSync, readSync, closeSync, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "node:fs";
|
|
29318
29333
|
import { watch as fsWatch } from "node:fs";
|
|
@@ -30480,6 +30495,7 @@ var init_dist5 = __esm({
|
|
|
30480
30495
|
init_retryController();
|
|
30481
30496
|
init_agenticRunner();
|
|
30482
30497
|
init_pressure_gate();
|
|
30498
|
+
init_constraint_learner();
|
|
30483
30499
|
init_nexusBackend();
|
|
30484
30500
|
init_cascadeBackend();
|
|
30485
30501
|
init_flowstatePrompt();
|
package/package.json
CHANGED