feat(FN-4455): complete Step 5 — migrate memory mode resolution and tests
Fusion-Task-Id: FN-4455 Fusion-Task-Lineage: 735091fa-9d42-4f23-9c5b-3e5889da99a6
This commit is contained in:
@@ -55,7 +55,7 @@ async function createHarness(mode: "full" | "index" | "off"): Promise<Harness> {
|
||||
const globalDir = mkdtempSync(join(tmpdir(), "hb-memory-mode-global-"));
|
||||
const taskStore = new TaskStore(rootDir, globalDir, { inMemoryDb: true });
|
||||
await taskStore.init();
|
||||
await taskStore.updateSettings({ agentMemoryInclusionMode: mode });
|
||||
await taskStore.updateGlobalSettings({ agentMemoryInclusionMode: mode });
|
||||
const agentStore = new AgentStore({ rootDir: taskStore.getFusionDir(), taskStore, inMemoryDb: true });
|
||||
const agent = await agentStore.createAgent({
|
||||
name: "Memory Mode Agent",
|
||||
@@ -125,6 +125,7 @@ describe("heartbeat memory inclusion mode", () => {
|
||||
|
||||
const transitionLogs = appendSpy.mock.calls.filter(([, , entry]) => entry.text.includes("Agent memory inclusion mode:"));
|
||||
expect(transitionLogs).toHaveLength(1);
|
||||
expect(transitionLogs[0]?.[2].taskId).toBe("heartbeat");
|
||||
|
||||
await harness.agentStore.updateAgent(harness.agentId, {
|
||||
runtimeConfig: { enabled: true, agentMemoryInclusionMode: "off", lastAgentMemoryInclusionMode: "index" },
|
||||
|
||||
@@ -2089,7 +2089,7 @@ export class HeartbeatMonitor {
|
||||
|
||||
const resolvedMemoryMode = resolveAgentMemoryInclusionMode({
|
||||
agent,
|
||||
projectSettings: memorySettings,
|
||||
globalSettings: memorySettings,
|
||||
});
|
||||
const priorMemoryMode = agent.runtimeConfig?.lastAgentMemoryInclusionMode;
|
||||
const baseHeartbeatSystemPrompt = adjustHeartbeatMemoryPrimer(
|
||||
@@ -2157,13 +2157,10 @@ export class HeartbeatMonitor {
|
||||
|
||||
if (priorMemoryMode !== resolvedMemoryMode.mode) {
|
||||
const from = priorMemoryMode ? priorMemoryMode : "(initial)";
|
||||
const runContextTaskId = typeof run.contextSnapshot?.taskId === "string"
|
||||
? run.contextSnapshot.taskId
|
||||
: undefined;
|
||||
try {
|
||||
await this.store.appendRunLog(agentId, run.id, {
|
||||
timestamp: new Date().toISOString(),
|
||||
taskId: taskId ?? runContextTaskId ?? "heartbeat",
|
||||
taskId: taskId ?? "heartbeat",
|
||||
type: "text",
|
||||
text: `Agent memory inclusion mode: ${from} → ${resolvedMemoryMode.mode} (source: ${resolvedMemoryMode.source})`,
|
||||
});
|
||||
|
||||
@@ -2425,12 +2425,12 @@ export class TaskExecutor {
|
||||
if (agent.instructionsText || agent.instructionsPath) {
|
||||
try {
|
||||
const ratingSummary = await this.options.agentStore.getRatingSummary(agent.id);
|
||||
const mode = resolveAgentMemoryInclusionMode({ agent, projectSettings: settings }).mode;
|
||||
const mode = resolveAgentMemoryInclusionMode({ agent, globalSettings: settings }).mode;
|
||||
return await resolveAgentInstructions(agent, this.rootDir, ratingSummary, mode);
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
executorLog.warn(`${agent.id}: failed to load rating summary for instruction resolution, falling back to default instructions: ${msg}`);
|
||||
const mode = resolveAgentMemoryInclusionMode({ agent, projectSettings: settings }).mode;
|
||||
const mode = resolveAgentMemoryInclusionMode({ agent, globalSettings: settings }).mode;
|
||||
return await resolveAgentInstructions(agent, this.rootDir, undefined, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ export async function reviewStep(
|
||||
const agents = await options.agentStore.listAgents({ role: "reviewer" });
|
||||
for (const agent of agents) {
|
||||
if (agent.instructionsText || agent.instructionsPath) {
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent, projectSettings: options.settings }).mode;
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent, globalSettings: options.settings }).mode;
|
||||
reviewerInstructions = await resolveAgentInstructions(agent, options.rootDir, undefined, memoryMode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1039,7 +1039,7 @@ export class TriageProcessor {
|
||||
// Resolve per-agent custom instructions for the triage role or assigned agent.
|
||||
let triageInstructions = "";
|
||||
if (assignedAgent) {
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent: assignedAgent, projectSettings: settings }).mode;
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent: assignedAgent, globalSettings: settings }).mode;
|
||||
triageInstructions = await resolveAgentInstructionsWithRatings(
|
||||
assignedAgent,
|
||||
this.rootDir,
|
||||
@@ -1052,7 +1052,7 @@ export class TriageProcessor {
|
||||
for (const agent of agents) {
|
||||
triageRuntimeHint ??= extractRuntimeHint(agent.runtimeConfig);
|
||||
if (agent.instructionsText || agent.instructionsPath || agent.soul || agent.memory) {
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent, projectSettings: settings }).mode;
|
||||
const memoryMode = resolveAgentMemoryInclusionMode({ agent, globalSettings: settings }).mode;
|
||||
triageInstructions = await resolveAgentInstructions(agent, this.rootDir, undefined, memoryMode);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user