From 51dbeb0cac99f7d9f6250ec4d11e9649e3f4b968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sun, 22 Mar 2026 03:59:09 -0400 Subject: [PATCH] feat(02-02): enhance agent prompts for non-code task deliverables - Add deliverable requirement sections for research and content tasks in prompt-builder - Research tasks instruct agents to produce knowledge entries, documents, or substantial comments - Content tasks instruct agents to produce documents, social media drafts, or substantial comments - Auto-infer task_type from assignee department on task creation in api-server - Import inferTaskType in both prompt-builder and api-server --- src/main/api-server.ts | 10 ++++++++++ src/main/prompt-builder.ts | 31 ++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/api-server.ts b/src/main/api-server.ts index 01af6b4b..33e0281c 100644 --- a/src/main/api-server.ts +++ b/src/main/api-server.ts @@ -7,6 +7,7 @@ import { validateAgentToken, type TokenPayload } from "./agent-auth"; import { canAssignTask, canControlAgent, canManageGoal, canManageOrganization, canManageProject, canUpdateTask } from "./agent-permissions"; import { resolveApprovalDecision, shouldAutoApproveApproval } from "./approval-policy"; import type { AppDatabase } from "./database"; +import { inferTaskType } from "./connector-matching"; import { dispatchAgentMessage } from "./message-dispatch"; import type { DesktopEvent } from "@shared/types"; @@ -537,6 +538,15 @@ export class AgentApiServer { return; } + // Auto-infer task_type from assignee's department + if (input.assigneeAgentId) { + try { + const assignee = this.db.getAgent(input.assigneeAgentId); + const inferredType = inferTaskType(assignee.department); + this.db.setTaskType(id, inferredType); + } catch { /* best effort -- agent may not exist or setTaskType may fail */ } + } + this.db.addActivity({ companyId, actor: token.agentId, diff --git a/src/main/prompt-builder.ts b/src/main/prompt-builder.ts index 9195b728..524a1930 100644 --- a/src/main/prompt-builder.ts +++ b/src/main/prompt-builder.ts @@ -2,7 +2,7 @@ import type { AgentRecord, AgentMessageRecord, ApprovalRecord, ConnectorId, Docu import type { AppLocale } from "@shared/locale"; import { DEPARTMENT_LABELS } from "@shared/constants"; import { getLocalePromptInstruction } from "@shared/localization"; -import { getConnectorStrengths } from "./connector-matching"; +import { getConnectorStrengths, inferTaskType } from "./connector-matching"; interface PromptContext { agent: AgentRecord; @@ -205,6 +205,35 @@ ${relevantProjects.map((p) => `- [${p.id}] ${p.name}: ${p.description || ""} (st ${ctx.task.projectId ? `- Project: ${ctx.projects.find((p) => p.id === ctx.task!.projectId)?.name ?? ctx.task.projectId}` : ""} ${ctx.task.goalId ? `- Goal: ${ctx.goals.find((g) => g.id === ctx.task!.goalId)?.title ?? ctx.task.goalId}` : ""} `); + + // Add deliverable requirements based on task type for non-code tasks + const taskType = ((ctx.task as unknown as Record).task_type as string) ?? inferTaskType(ctx.agent.department); + + if (taskType === "research") { + sections.push(`# Deliverable Requirements (Research Task) +This is a research task. You MUST produce a tangible deliverable before marking it complete: + +**Required:** Create at least ONE of: +1. A knowledge entry via POST /api/companies/${ctx.agent.companyId}/knowledge with your findings +2. A document via POST /api/companies/${ctx.agent.companyId}/documents with a structured report +3. A detailed comment on the task via PATCH /api/issues/${ctx.task.id} with body containing your analysis (minimum 100 words) + +Do NOT mark the task as done or in_review without producing one of these artifacts. +Your manager will reject the task if no deliverable is found. +`); + } else if (taskType === "content") { + sections.push(`# Deliverable Requirements (Content Task) +This is a content creation task. You MUST produce a tangible deliverable before marking it complete: + +**Required:** Create at least ONE of: +1. A document via POST /api/companies/${ctx.agent.companyId}/documents with the content draft +2. A social media draft via the social media queue +3. A detailed comment on the task via PATCH /api/issues/${ctx.task.id} with the content (minimum 100 words) + +Do NOT mark the task as done or in_review without producing one of these artifacts. +Your manager will reject the task if no deliverable is found. +`); + } } if (ctx.assignedTasks.length > 0) {