fix(FN-5060): stabilize dedup typing and engine expectations

This commit is contained in:
Fusion (runfusion.ai)
2026-05-18 18:18:56 -07:00
committed by gsxdsm
parent 4c3869403d
commit 2b96475fdd
5 changed files with 26 additions and 21 deletions

View File

@@ -183,13 +183,13 @@ describe("createDelegateTaskTool", () => {
description: "Write tests",
}, undefined as any, undefined as any, undefined as any);
expect(taskStore.createTask).toHaveBeenCalledWith({
expect(taskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
description: "Write tests",
dependencies: undefined,
column: "todo",
assignedAgentId: "agent-001",
source: { sourceType: "api" },
}, expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
source: expect.objectContaining({ sourceType: "api" }),
}), expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
const text = (result.content[0] as { text: string }).text;
expect(text).toContain("Delegated to Bob (agent-001)");
@@ -295,7 +295,7 @@ describe("createDelegateTaskTool", () => {
expect(taskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
assignedAgentId: "agent-009",
source: { sourceType: "api" },
source: expect.objectContaining({ sourceType: "api" }),
}), expect.anything());
});
@@ -338,7 +338,10 @@ describe("createDelegateTaskTool", () => {
}, undefined as any, undefined as any, undefined as any);
expect(taskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
source: { sourceType: "api", sourceMetadata: { executorRoleOverride: true } },
source: expect.objectContaining({
sourceType: "api",
sourceMetadata: expect.objectContaining({ executorRoleOverride: true }),
}),
}), expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
});
@@ -364,13 +367,13 @@ describe("createDelegateTaskTool", () => {
dependencies: ["FN-010"],
}, undefined as any, undefined as any, undefined as any);
expect(taskStore.createTask).toHaveBeenCalledWith({
expect(taskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
description: "Integration test",
dependencies: ["FN-010"],
column: "todo",
assignedAgentId: "agent-001",
source: { sourceType: "api" },
}, expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
source: expect.objectContaining({ sourceType: "api" }),
}), expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
const text = (result.content[0] as { text: string }).text;
expect(text).toContain("depends on: FN-010");

View File

@@ -3085,17 +3085,17 @@ describe("executeHeartbeat", () => {
await monitor.executeHeartbeat({ agentId: "agent-001", source: "on_demand" });
expect(mockTaskStore.createTask).toHaveBeenCalledWith({
expect(mockTaskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
description: "Follow-up task",
dependencies: undefined,
column: "triage",
priority: undefined,
source: {
source: expect.objectContaining({
sourceType: "agent_heartbeat",
sourceAgentId: "agent-001",
sourceRunId: undefined,
},
}, expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
}),
}), expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
});
it("forwards explicit priority when fn_task_create tool is called", async () => {

View File

@@ -132,17 +132,17 @@ describe("createHeartbeatTools", () => {
const result = await createTool.execute("call-1", { description: "Follow-up task" }, undefined as any, undefined as any, undefined as any);
expect(mockTaskStore.createTask).toHaveBeenCalledWith({
expect(mockTaskStore.createTask).toHaveBeenCalledWith(expect.objectContaining({
description: "Follow-up task",
dependencies: undefined,
column: "triage",
priority: undefined,
source: {
source: expect.objectContaining({
sourceType: "agent_heartbeat",
sourceAgentId: "agent-001",
sourceRunId: undefined,
},
}, expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
}),
}), expect.objectContaining({ settings: { autoSummarizeTitles: false } }));
const responseText = result.content[0] && "text" in result.content[0] ? result.content[0].text : "";
expect(responseText).toContain("Created FN-100");

View File

@@ -595,6 +595,8 @@ async function getAgentMemoryWindow(rootDir: string, agentMemory: AgentMemoryCon
type AgentTaskCreationOptions = {
rootDir?: string;
bypassDuplicateCheck?: boolean;
acknowledgedDuplicates?: string[];
};
export async function createAgentTask(
@@ -611,8 +613,8 @@ export async function createAgentTask(
description: input.description,
}, {
lockScope: rootDir ?? store.getRootDir?.() ?? "agent-tools",
bypass: input.bypassDuplicateCheck === true,
acknowledgedDuplicates: input.acknowledgedDuplicates,
bypass: options?.bypassDuplicateCheck === true,
acknowledgedDuplicates: options?.acknowledgedDuplicates,
logger: log,
});
@@ -625,9 +627,9 @@ export async function createAgentTask(
...(input.source?.sourceMetadata ?? {}),
...(guard.fingerprint ? { contentFingerprint: guard.fingerprint } : {}),
};
const nextSource = input.source || Object.keys(sourceMetadata).length > 0
const nextSource = input.source
? {
...(input.source ?? {}),
...input.source,
sourceMetadata: Object.keys(sourceMetadata).length > 0 ? sourceMetadata : undefined,
}
: undefined;