Q10: wake tasks no longer carry a truncated copy of the message

Manual re-runs of a chat wake answer the same thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 03:36:22 -04:00
1 parent abe9534350
commit 31ab919334
4 files changed
+53 -6

No files matched your search

+5 -5
View File
@@ -130,7 +130,7 @@ export class ChatAgentWakeService {
const taskId = this.organization.createTask({
orgId: input.orgId,
title: direct ? `Reply to ${from}` : `Reply to ${from} in #${space.name}`,
description: this.mentionTaskDescription(input, from, space.name, direct),
description: this.mentionTaskDescription(from, space.name, direct),
status: TASK_STATUS.BACKLOG,
assigneeAgentId: agent.id,
risk: RISK_LEVEL.LOW,
@@ -296,15 +296,15 @@ export class ChatAgentWakeService {
return `Chat mention: ${title.length > 64 ? `${title.slice(0, 61)}...` : title}`;
}
private mentionTaskDescription(input: SendMessageInput, from: string, channel: string, direct: boolean): string {
const said = input.bodyMd.trim();
const where = direct ? `${from} messaged you directly:` : `${from} addressed you in #${channel}:`;
private mentionTaskDescription(from: string, channel: string, direct: boolean): string {
const where = direct
? `${from} messaged you directly; their full message is in the thread below.`
: `${from} addressed you in #${channel}; their full message is in the thread below.`;
const how = direct
? `Reply to ${from} in your direct conversation: call send_message with to="${from}" and this thread_id.`
: `Reply to ${from} in this thread.`;
return [
where,
`"${said.length > 400 ? `${said.slice(0, 397)}...` : said}"`,
"",
`${how} Answer what they asked, give your honest take, push back if you disagree, or hand work over — speak as yourself, the way a colleague would, not as a status report.`,
].join("\n");
@@ -665,10 +665,26 @@ export class TaskExecutionService {
providerIds: [provider.id],
scope: "task_run",
credentialAccess: "provider_runtime_only",
...this.chatWakeSource(orgId, task),
}),
};
}
/** A re-run of a chat wake answers the same thread. */
private chatWakeSource(orgId: string, task: TaskExecutionTaskRow): { sourceThreadId: string; sourceMessageId: string } | Record<string, never> {
if (task.origin !== "chat_wake") return {};
const row = this.db.prepare(`
select json_extract(secret_scope_json, '$.sourceThreadId') as thread_id,
json_extract(secret_scope_json, '$.sourceMessageId') as message_id
from task_runs
where task_id = ? and org_id = ? and json_extract(secret_scope_json, '$.sourceThreadId') is not null
order by created_at desc
limit 1
`).get(task.id, orgId) as { thread_id: string; message_id: string } | undefined;
if (!row) throw new Error(`Chat wake task ${task.id} has no recorded source thread.`);
return { sourceThreadId: row.thread_id, sourceMessageId: row.message_id };
}
private requireServiceIdentity(orgId: string, agentId: string): string {
const row = this.db.prepare("select id from service_identities where org_id = ? and agent_id = ?")
.get(orgId, agentId) as { id: string } | undefined;
+1
View File
@@ -14,6 +14,7 @@ export interface TaskExecutionTaskRow {
priority: string;
requires_filesystem: number;
handoff_json: string | null;
origin: string | null;
}
export interface TaskExecutionAgentRow {