fix(FN-2107): normalize task ID handling for task creation tools

- Return the created task ID directly from runTaskPlan and propagate it through fn_task_plan
- Remove hardcoded FN-### log parsing so CLI extension supports structured IDs like PROJ-042
- Add heartbeat fallback parsing from task_create text output when details.taskId is absent
- Expand engine and CLI tests to cover structured task IDs and updated task-plan return behavior
This commit is contained in:
Fusion
2026-04-19 03:21:26 -07:00
committed by gsxdsm
parent e0f6647d11
commit 3f8a2e9442
7 changed files with 106 additions and 33 deletions

View File

@@ -9,6 +9,7 @@ import {
HEARTBEAT_SYSTEM_PROMPT_NO_TASK,
} from "./agent-heartbeat.js";
import { AgentLogger } from "./agent-logger.js";
import * as agentTools from "./agent-tools.js";
import type { AgentStore, AgentHeartbeatRun, TaskStore, TaskDetail, Agent, MessageStore, Message, AgentBudgetStatus } from "@fusion/core";
// Mock logger to suppress noise in test output
@@ -3290,6 +3291,35 @@ describe("HeartbeatMonitor", () => {
);
});
it("task_create tracking falls back to parsing text when details.taskId is missing", async () => {
const store = createMockStore();
const createTaskCreateToolSpy = vi.spyOn(agentTools, "createTaskCreateTool").mockReturnValue({
name: "task_create",
label: "Create Task",
description: "Create a task",
parameters: {} as any,
execute: vi.fn().mockResolvedValue({
content: [{ type: "text", text: "Created PROJ-777: Follow-up task" }],
details: {},
}),
} as any);
const monitor = new HeartbeatMonitor({ store, taskStore: mockTaskStore, rootDir: "/tmp" });
try {
const tools = monitor.createHeartbeatTools("agent-001", mockTaskStore, "FN-001");
await tools[0]!.execute("call-1", { description: "Follow-up task" }, undefined as any, undefined as any, undefined as any);
expect(mockTaskStore.logEntry).toHaveBeenCalledWith(
"PROJ-777",
"Created by agent agent-001 during heartbeat run",
undefined,
undefined,
);
} finally {
createTaskCreateToolSpy.mockRestore();
}
});
it("task_create tracking handles missing details gracefully", async () => {
const store = createMockStore();
const missingDetailsTaskStore = createMockTaskStoreForTools({