feat(KB-141): add dependency awareness to triage system prompt and task_get tool
- Add 'Dependency awareness' section to TRIAGE_SYSTEM_PROMPT instructing agent to call task_get on dependencies before writing specs - Update task_get tool description to mention reading dependency task specs - Add test verifying system prompt contains dependency awareness instructions - Add test verifying task_get tool description mentions dependency specs
This commit is contained in:
@@ -404,6 +404,73 @@ describe("buildSpecificationPrompt", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("TRIAGE_SYSTEM_PROMPT and task_get tool", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("system prompt contains dependency awareness instructions", async () => {
|
||||||
|
const store = createMockStore();
|
||||||
|
|
||||||
|
mockedCreateHaiAgent.mockResolvedValue({
|
||||||
|
session: {
|
||||||
|
prompt: vi.fn().mockResolvedValue(undefined),
|
||||||
|
dispose: vi.fn(),
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
const triage = new TriageProcessor(store, "/tmp/test");
|
||||||
|
await triage.specifyTask({
|
||||||
|
id: "KB-001",
|
||||||
|
title: "Test",
|
||||||
|
description: "Test",
|
||||||
|
column: "triage",
|
||||||
|
dependencies: [],
|
||||||
|
steps: [],
|
||||||
|
currentStep: 0,
|
||||||
|
log: [],
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const callArgs = mockedCreateHaiAgent.mock.calls[0][0];
|
||||||
|
const systemPrompt = callArgs.systemPrompt as string;
|
||||||
|
expect(systemPrompt).toContain("## Dependency awareness");
|
||||||
|
expect(systemPrompt).toContain("call `task_get` on that task ID to read its PROMPT.md");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("task_get tool description mentions reading dependency specs", async () => {
|
||||||
|
const store = createMockStore();
|
||||||
|
|
||||||
|
mockedCreateHaiAgent.mockResolvedValue({
|
||||||
|
session: {
|
||||||
|
prompt: vi.fn().mockResolvedValue(undefined),
|
||||||
|
dispose: vi.fn(),
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
const triage = new TriageProcessor(store, "/tmp/test");
|
||||||
|
await triage.specifyTask({
|
||||||
|
id: "KB-001",
|
||||||
|
title: "Test",
|
||||||
|
description: "Test",
|
||||||
|
column: "triage",
|
||||||
|
dependencies: [],
|
||||||
|
steps: [],
|
||||||
|
currentStep: 0,
|
||||||
|
log: [],
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const callArgs = mockedCreateHaiAgent.mock.calls[0][0];
|
||||||
|
const tools = callArgs.customTools as any[];
|
||||||
|
const taskGetTool = tools.find((t: any) => t.name === "task_get");
|
||||||
|
expect(taskGetTool).toBeDefined();
|
||||||
|
expect(taskGetTool.description).toContain("read dependency task specs");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function createEnoentError(path = "/fake/path"): NodeJS.ErrnoException {
|
function createEnoentError(path = "/fake/path"): NodeJS.ErrnoException {
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
new Error(`ENOENT: no such file or directory, open '${path}'`),
|
new Error(`ENOENT: no such file or directory, open '${path}'`),
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ If a task already covers the same work (even if worded differently), do NOT
|
|||||||
write a PROMPT.md. Instead, write a single line to the output file:
|
write a PROMPT.md. Instead, write a single line to the output file:
|
||||||
\`DUPLICATE: {existing-task-id}\`
|
\`DUPLICATE: {existing-task-id}\`
|
||||||
|
|
||||||
|
## Dependency awareness
|
||||||
|
When you plan to list a task in the \`## Dependencies\` section, first call \`task_get\` on that task ID to read its PROMPT.md.
|
||||||
|
Use what you learn — file scope, APIs, patterns, completion criteria — to make the new spec accurate: reference the right paths, avoid conflicting assumptions, and describe what the dependency must deliver before this task starts.
|
||||||
|
If the dependency task has no PROMPT.md yet (not yet specified), note that in the Dependencies section.
|
||||||
|
|
||||||
## Guidelines
|
## Guidelines
|
||||||
- Read the project structure and relevant source files to understand context BEFORE writing
|
- Read the project structure and relevant source files to understand context BEFORE writing
|
||||||
- Be specific — name actual files, functions, and patterns from the codebase
|
- Be specific — name actual files, functions, and patterns from the codebase
|
||||||
@@ -373,7 +378,7 @@ export class TriageProcessor {
|
|||||||
label: "Get Task",
|
label: "Get Task",
|
||||||
description:
|
description:
|
||||||
"Get full details of a specific task including its PROMPT.md content. " +
|
"Get full details of a specific task including its PROMPT.md content. " +
|
||||||
"Use to verify whether a similar task is actually a duplicate.",
|
"Use to verify duplicates and to read dependency task specs before writing a new PROMPT.md.",
|
||||||
parameters: taskGetParams,
|
parameters: taskGetParams,
|
||||||
execute: async (_callId: string, params: Static<typeof taskGetParams>) => {
|
execute: async (_callId: string, params: Static<typeof taskGetParams>) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user