fix: replace pid:-1 sentinel with process.pid to prevent false process_lost

The adapter was calling onSpawn({ pid: -1 }) as a sentinel value for
K8s Jobs (which run out-of-process), then the server's orphan reaper
was checking isProcessAlive(-1) which always returns false, causing
legitimate runs to be reaped as 'process_lost'.

Using process.pid (the Paperclip server's own PID) is always alive
while the adapter runs in-process, preventing false reaping.

Fixes FAR-116.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Iceman
2026-04-21 18:09:41 +00:00
parent 31328dd85b
commit 5926b302e5
20 changed files with 400 additions and 94 deletions
+6 -1
View File
@@ -6,6 +6,9 @@ export function parseClaudeStreamJson(stdout) {
let model = "";
let finalResult = null;
const assistantTexts = [];
// Belt-and-braces dedup: track seen text blocks to filter duplicates
// caused by log stream reconnects replaying overlapping windows.
const seenTexts = new Set();
for (const rawLine of stdout.split(/\r?\n/)) {
const line = rawLine.trim();
if (!line)
@@ -29,8 +32,10 @@ export function parseClaudeStreamJson(stdout) {
const block = entry;
if (asString(block.type, "") === "text") {
const text = asString(block.text, "");
if (text)
if (text && !seenTexts.has(text)) {
seenTexts.add(text);
assistantTexts.push(text);
}
}
}
continue;