feat: Auto-Compact nach N User-Messages — verhindert E2BIG bei langer Session
E2BIG (Argument list too long) tritt auf wenn aria-core's Subprocess-
Spawn das Linux argv-Limit (~128KB-2MB) sprengt. Bei >140 Messages
samt Memory + System-Prompt + Tools laeuft das voll, ARIA antwortet
nur noch leer auf jede Anfrage.
Bridge zaehlt jetzt User-Nachrichten in send_to_core; bei COMPACT_AFTER_MESSAGES
(env, default 140) wird automatisch:
- Sessions geleert (rm sessions/*.jsonl + sessions.json = {})
- aria-core neu gestartet
- User informiert "Konversation komprimiert, letzte Nachricht nochmal"
Plus manueller "🧹 Konversation komprimieren"-Button in App-Settings
und 🧹 Compact-Button in Diagnostic-Thinking-Indicator.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1358,6 +1358,43 @@ const server = http.createServer((req, res) => {
|
||||
res.end(JSON.stringify({ ok: false, error: err.message }));
|
||||
});
|
||||
return;
|
||||
} else if (req.url === "/api/aria-session-reset" && req.method === "POST") {
|
||||
// Sessions weg + Container neu — fuer Compact-After-N-Messages.
|
||||
// E2BIG bei zu langen Sessions: argv beim Subprocess-spawn ueberschritten.
|
||||
log("warn", "server", "HTTP /api/aria-session-reset — Sessions loeschen + Restart");
|
||||
broadcast({ type: "watchdog", status: "fixing", message: "Sessions werden geleert — ARIA bekommt frischen Start" });
|
||||
dockerExec("aria-core", "rm -f /home/node/.openclaw/agents/main/sessions/*.jsonl /home/node/.openclaw/agents/main/sessions/*.lock 2>&1 && echo '{}' > /home/node/.openclaw/agents/main/sessions/sessions.json")
|
||||
.then(() => {
|
||||
// Restart via Docker-API (gleicher Pfad wie /api/aria-restart)
|
||||
const restartReq = http.request({
|
||||
socketPath: "/var/run/docker.sock",
|
||||
path: "/containers/aria-core/restart?t=10",
|
||||
method: "POST",
|
||||
headers: { "Content-Length": 0 },
|
||||
timeout: 30000,
|
||||
}, (dRes) => {
|
||||
if (dRes.statusCode === 204) {
|
||||
log("info", "server", "aria-session-reset OK");
|
||||
broadcast({ type: "watchdog", status: "fixed", message: "Sessions geleert, ARIA neu gestartet" });
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: true }));
|
||||
} else {
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: `Docker-API ${dRes.statusCode}` }));
|
||||
}
|
||||
});
|
||||
restartReq.on("error", (err) => {
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: err.message }));
|
||||
});
|
||||
restartReq.end();
|
||||
})
|
||||
.catch((err) => {
|
||||
log("error", "server", `aria-session-reset Cleanup fehlgeschlagen: ${err.message}`);
|
||||
res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ ok: false, error: err.message }));
|
||||
});
|
||||
return;
|
||||
} else if (req.url === "/api/aria-restart" && req.method === "POST") {
|
||||
// Harter Restart — fuer Faelle wo doctor --fix nicht reicht (alive aber
|
||||
// haengender Run). Geht ueber Docker-API (Socket), kein CLI noetig.
|
||||
|
||||
Reference in New Issue
Block a user