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
This commit is contained in:
1 parent
9a1671981a
commit
51dbeb0cac
2 files changed
+40
-1
No files matched your search
@@ -7,6 +7,7 @@ import { validateAgentToken, type TokenPayload } from "./agent-auth";
|
|||||||
import { canAssignTask, canControlAgent, canManageGoal, canManageOrganization, canManageProject, canUpdateTask } from "./agent-permissions";
|
import { canAssignTask, canControlAgent, canManageGoal, canManageOrganization, canManageProject, canUpdateTask } from "./agent-permissions";
|
||||||
import { resolveApprovalDecision, shouldAutoApproveApproval } from "./approval-policy";
|
import { resolveApprovalDecision, shouldAutoApproveApproval } from "./approval-policy";
|
||||||
import type { AppDatabase } from "./database";
|
import type { AppDatabase } from "./database";
|
||||||
|
import { inferTaskType } from "./connector-matching";
|
||||||
import { dispatchAgentMessage } from "./message-dispatch";
|
import { dispatchAgentMessage } from "./message-dispatch";
|
||||||
import type { DesktopEvent } from "@shared/types";
|
import type { DesktopEvent } from "@shared/types";
|
||||||
|
|
||||||
@@ -537,6 +538,15 @@ export class AgentApiServer {
|
|||||||
return;
|
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({
|
this.db.addActivity({
|
||||||
companyId,
|
companyId,
|
||||||
actor: token.agentId,
|
actor: token.agentId,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { AgentRecord, AgentMessageRecord, ApprovalRecord, ConnectorId, Docu
|
|||||||
import type { AppLocale } from "@shared/locale";
|
import type { AppLocale } from "@shared/locale";
|
||||||
import { DEPARTMENT_LABELS } from "@shared/constants";
|
import { DEPARTMENT_LABELS } from "@shared/constants";
|
||||||
import { getLocalePromptInstruction } from "@shared/localization";
|
import { getLocalePromptInstruction } from "@shared/localization";
|
||||||
import { getConnectorStrengths } from "./connector-matching";
|
import { getConnectorStrengths, inferTaskType } from "./connector-matching";
|
||||||
|
|
||||||
interface PromptContext {
|
interface PromptContext {
|
||||||
agent: AgentRecord;
|
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.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}` : ""}
|
${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<string, unknown>).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) {
|
if (ctx.assignedTasks.length > 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user