fix(conscience): I read the room now, not just the memory I was born with

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.
This commit is contained in:
Ani Tunturi
2026-03-27 16:13:31 -04:00
parent 73857e05c2
commit 73a8e0e07f

View File

@@ -2496,7 +2496,18 @@ async function runBidirectionalMode(
} catch { } catch {
debugWarn("memory", "Failed to fetch parent system prompt for reflection; proceeding without it"); 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; const conscienceAgentId = process.env.CONSCIENCE_AGENT_ID;
// When running as conscience, append the aster/ folder content so Aster // When running as conscience, append the aster/ folder content so Aster