fix(agent): return collected output when exec auto-backgrounds
Previously, when a command exceeded yieldMs (default 5s) and was auto-backgrounded, exec returned an empty output string. This caused agents to misinterpret slow commands (like curl) as failed, leading to infinite retry loops. Changes: - Implement three-layer buffer system (pending 30KB + aggregated 200KB + tail 1KB) - Return collected output snapshot when backgrounding instead of empty string - Increase default yieldMs from 5s to 10s for better coverage - Add auto sweeper for terminated process cleanup (30min TTL) - Register process immediately on spawn to capture all output Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a5f979fceb
commit
cbb13b26d1
3 changed files with 172 additions and 56 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
PROCESS_REGISTRY,
|
||||
registerProcess,
|
||||
cleanupTerminatedProcesses,
|
||||
getFullOutput,
|
||||
} from "./process-registry.js";
|
||||
|
||||
const ProcessSchema = Type.Object({
|
||||
|
|
@ -138,10 +139,10 @@ export function createProcessTool(defaultCwd?: string): AgentTool<typeof Process
|
|||
details: { id, running: false },
|
||||
};
|
||||
}
|
||||
const output = entry.outputBuffer.join("");
|
||||
const { output, truncated } = getFullOutput(entry);
|
||||
const running = entry.exitCode === null;
|
||||
return {
|
||||
content: [{ type: "text", text: output || "(no output)" }],
|
||||
content: [{ type: "text", text: (output || "(no output)") + (truncated ? "\n[output truncated]" : "") }],
|
||||
details: { id, running, exitCode: entry.exitCode, output },
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue