refactor: slim thread execution prompts
This commit is contained in:
@@ -5466,19 +5466,17 @@ function buildDispatchExecutionPrompt(input: {
|
||||
);
|
||||
const requestText = requestMessage?.body ?? input.plan.summary;
|
||||
return [
|
||||
"你正在执行 Boss 控制台的线程分发任务。",
|
||||
"你正在以目标线程身份处理一条来自 Boss 群聊的任务。",
|
||||
"你的输出必须是 JSON,并且只能包含两个字符串字段:rawThreadReply、replyBody。",
|
||||
"rawThreadReply:写成目标线程直接回到群里的原始结果,不要冒充主 Agent。",
|
||||
"rawThreadReply:写成目标线程直接回到群里的有效结果,不要冒充主 Agent,不要夹带内部字段、编号或调度说明。",
|
||||
"replyBody:写成主 Agent 给群里的简短汇总,必须保留“主 Agent 汇总:”前缀。",
|
||||
"不要输出 Markdown 代码块,不要输出额外解释。",
|
||||
`groupProjectId: ${input.groupProject.id}`,
|
||||
`groupProjectName: ${input.groupProject.name}`,
|
||||
`threadProjectId: ${input.target.projectId}`,
|
||||
`threadId: ${input.target.threadId}`,
|
||||
`threadTitle: ${input.target.threadDisplayName}`,
|
||||
`folderName: ${input.target.folderName}`,
|
||||
`requestText: ${requestText}`,
|
||||
`dispatchSummary: ${input.plan.summary}`,
|
||||
`群聊名称:${input.groupProject.name}`,
|
||||
`目标线程:${input.target.threadDisplayName}`,
|
||||
"当前群聊请求:",
|
||||
requestText.trim(),
|
||||
"主 Agent 推荐摘要:",
|
||||
input.plan.summary.trim(),
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -197,17 +197,15 @@ function buildMasterAgentInstructions() {
|
||||
}
|
||||
|
||||
function buildThreadConversationReplyPrompt(project: Project, requestText: string) {
|
||||
const threadTitle = project.threadMeta.threadDisplayName?.trim() || project.name;
|
||||
return [
|
||||
"你正在代表某个 Codex 线程回复 Boss 控制台里的单线程会话。",
|
||||
"你不是主 Agent,不要使用“主 Agent”口吻,不要写总结,不要解释调度过程。",
|
||||
"请直接像该线程本人一样,用中文回复用户当前这条消息。",
|
||||
"如果信息不足,要明确说缺什么;不要假装已经执行过设备操作。",
|
||||
"输出要求:只输出线程要回给用户的正文,不要输出 JSON、代码块或额外前缀。",
|
||||
`threadProjectId: ${project.id}`,
|
||||
`threadTitle: ${project.threadMeta.threadDisplayName}`,
|
||||
`folderName: ${project.threadMeta.folderName}`,
|
||||
`deviceIds: ${project.deviceIds.join(",")}`,
|
||||
`requestText: ${requestText}`,
|
||||
"你现在以目标线程身份直接回复用户。",
|
||||
`线程名称:${threadTitle}`,
|
||||
"只回复对用户真正有用的内容,不要发送内部字段、项目编号、目录名、设备编号、调度解释或多余前缀。",
|
||||
"不要自称主 Agent,不要解释系统如何分发,不要输出 JSON、代码块或额外格式包装。",
|
||||
"如果信息不足,直接说明缺什么;不要假装已经执行过设备操作。",
|
||||
"用户当前消息:",
|
||||
requestText.trim(),
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,12 @@ async function createConfirmedDispatchExecution() {
|
||||
task.requestMessageId === messagePayload.dispatchPlan?.planId,
|
||||
);
|
||||
assert.ok(executionTask, "expected a queued dispatch execution master-agent task");
|
||||
assert.ok(executionTask?.executionPrompt?.includes("请主 Agent 推荐要先同步的线程"));
|
||||
assert.ok(executionTask?.executionPrompt?.includes(executionTask?.targetThreadDisplayName ?? ""));
|
||||
assert.ok(!executionTask?.executionPrompt?.includes("groupProjectId:"), "dispatch prompt should not include group project id labels");
|
||||
assert.ok(!executionTask?.executionPrompt?.includes("threadProjectId:"), "dispatch prompt should not include thread project id labels");
|
||||
assert.ok(!executionTask?.executionPrompt?.includes("threadId:"), "dispatch prompt should not include raw thread id labels");
|
||||
assert.ok(!executionTask?.executionPrompt?.includes("folderName:"), "dispatch prompt should not include folder labels");
|
||||
|
||||
return { groupProject, execution, executionTask };
|
||||
}
|
||||
|
||||
@@ -103,6 +103,11 @@ test("POST /api/v1/projects/[projectId]/messages enqueues a conversation task fo
|
||||
assert.ok(task, "expected a queued conversation_reply task for the single-thread project");
|
||||
assert.equal(task?.targetProjectId, singleProject.id);
|
||||
assert.equal(task?.targetThreadId, singleProject.threadMeta.threadId);
|
||||
assert.ok(task?.executionPrompt?.includes("请同步一下当前阻塞情况"));
|
||||
assert.ok(task?.executionPrompt?.includes(singleProject.threadMeta.threadDisplayName));
|
||||
assert.ok(!task?.executionPrompt?.includes("threadProjectId:"), "thread prompt should not include project id labels");
|
||||
assert.ok(!task?.executionPrompt?.includes("folderName:"), "thread prompt should not include folder labels");
|
||||
assert.ok(!task?.executionPrompt?.includes("deviceIds:"), "thread prompt should not include device id labels");
|
||||
});
|
||||
|
||||
test("POST /api/v1/master-agent/tasks/[taskId]/complete writes the raw thread reply back to the single-thread project", async () => {
|
||||
|
||||
Reference in New Issue
Block a user