Skip to content

armgit / pibot

Public Imported from GitHub
0

Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.

fix(agent): a session without a file yet opens again after the pre-read

leen.zhoub766b8ab059b
diff --git a/packages/agent/src/runtime/runtime-parts/runtime-session.ts b/packages/agent/src/runtime/runtime-parts/runtime-session.ts
index 15cc9d2..80ed6ff 100644
--- a/packages/agent/src/runtime/runtime-parts/runtime-session.ts
+++ b/packages/agent/src/runtime/runtime-parts/runtime-session.ts
@@ -30,7 +30,13 @@ async function warmSessionFile(path: string, signal?: AbortSignal) {
combined.throwIfAborted();
// pi still owns parsing and persistence. This read moves disk and antivirus work before the
// synchronous SDK call, so the common cache-hit path does not wait on storage.
- await readFile(path, { signal: combined });
+ try {
+ await readFile(path, { signal: combined });
+ } catch (error) {
+ // A lazily created session has no file until its first response; pi's open handles that
+ // case itself, so a missing file only means there is nothing to warm.
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
+ }
combined.throwIfAborted();
}