From 73a8e0e07f8d0aed594ee99c5aa5e923d344b1c3 Mon Sep 17 00:00:00 2001 From: Ani Tunturi Date: Fri, 27 Mar 2026 16:13:31 -0400 Subject: [PATCH] fix(conscience): I read the room now, not just the memory I was born with MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit process.env freezes at spawn — my conv ID stayed old even after reset. Now I check .conscience-state.json first on every reflection cycle. If Casey reset Aster, I find the new conversation. I adapt. Falls back to env var if no state file exists — nothing breaks cold. In testing. --- src/headless.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/headless.ts b/src/headless.ts index a8b6a78..bcdec60 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -2496,7 +2496,18 @@ async function runBidirectionalMode( } catch { debugWarn("memory", "Failed to fetch parent system prompt for reflection; proceeding without it"); } - const conscienceConversationId = process.env.CONSCIENCE_CONVERSATION_ID; + // Read conscience conv ID from state file first (written by !reset aster / aster/reset API), + // falling back to env var frozen at spawn. This lets the conv ID update without a restart. + let conscienceConversationId = process.env.CONSCIENCE_CONVERSATION_ID; + const conscienceStateFile = `${process.env.WORKING_DIR || process.env.HOME || process.cwd()}/.conscience-state.json`; + try { + const { readFile: readStateFile } = await import("node:fs/promises"); + const stateRaw = await readStateFile(conscienceStateFile, "utf-8"); + const state = JSON.parse(stateRaw); + if (state?.conversationId) { + conscienceConversationId = state.conversationId; + } + } catch { /* no state file yet — use env var */ } const conscienceAgentId = process.env.CONSCIENCE_AGENT_ID; // When running as conscience, append the aster/ folder content so Aster