Q1: keep other work's chat mentions out of task prompts

Every mention already wakes the agent through its own chat-wake task, so
ordinary tasks no longer inject the org-wide mention inbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 02:19:48 -04:00
1 parent b07eedbaa7
commit 77505aab8d
3 files changed
+72 -37

No files matched your search

@@ -15,7 +15,6 @@ import {
buildAgentInstructions,
buildTaskPrompt,
type ChatContextBlock,
type InboxContextBlock,
type GoalRow,
type ProjectRow,
type SkillRuntimeSnapshotRow,
@@ -142,7 +141,6 @@ export class TaskExecutionService {
workspace: workspace ? { id: workspace.id, localPath: workspace.local_path, writeAccess: task.requires_filesystem === 1 } : null,
};
const chatContext = this.loadChatContext(orgId, isolation);
const inboxContext = chatContext ? null : this.loadInboxContext(orgId, agent.id);
// The CEO is the c_suite role — the same predicate the grant system
// enforces — not "has no manager", which any board hire can match.
const isCeo = agent.role_level === "c_suite";
@@ -179,7 +177,6 @@ export class TaskExecutionService {
hasReports,
managerName: this.agentName(orgId, agent.manager_agent_id),
chatContext,
inboxContext,
priorCompletedRuns: this.completedRunCount(task.id, runId),
}),
toolContext,
@@ -555,26 +552,6 @@ export class TaskExecutionService {
};
}
private loadInboxContext(orgId: string, agentId: string): InboxContextBlock | null {
const messages = this.db.prepare(`
select m.body_md,
coalesce(a.name, e.display_name, m.sender_type) as sender_name,
s.name as channel_name
from chat_mentions cm
join chat_messages m on m.id = cm.message_id
join chat_spaces s on s.id = m.space_id
left join agents a on a.id = m.sender_id and m.sender_type = 'agent'
left join employees e on e.id = m.sender_id and m.sender_type = 'employee'
where cm.target_type = 'agent' and cm.target_id = ? and m.org_id = ? and m.deleted_at is null
order by m.created_at desc
limit 10
`).all(agentId, orgId) as Array<{ body_md: string; sender_name: string; channel_name: string }>;
if (messages.length === 0) return null;
return {
transcript: messages.reverse().map((m) => `[${m.sender_name} in #${m.channel_name}]: ${m.body_md}`).join("\n"),
};
}
private completedRunCount(taskId: string, excludingRunId: string): number {
const row = this.db.prepare("select count(*) as n from task_runs where task_id = ? and state = 'completed' and id <> ?")
.get(taskId, excludingRunId) as { n: number };
-14
View File
@@ -150,10 +150,6 @@ function roleVoice(input: AgentInstructionContext): string {
return "You own your craft. Ask the question early instead of guessing, do the work properly, and when you are stuck for more than a few minutes say so in the thread instead of spinning in place.";
}
export interface InboxContextBlock {
transcript: string;
}
export function buildTaskPrompt(input: {
task: TaskExecutionTaskRow;
agent: TaskExecutionAgentRow;
@@ -167,7 +163,6 @@ export function buildTaskPrompt(input: {
hasReports: boolean;
managerName: string | null;
chatContext: ChatContextBlock | null;
inboxContext: InboxContextBlock | null;
/** Completed runs this task already spent without reaching done. */
priorCompletedRuns: number;
}): string {
@@ -220,15 +215,6 @@ export function buildTaskPrompt(input: {
);
return lines.join("\n");
}
if (input.inboxContext) {
lines.push(
"",
"Recent messages that mention you:",
input.inboxContext.transcript,
"",
"Respond to anyone above who needs your input before starting the task.",
);
}
if (input.task.requires_filesystem === 1 && input.workspace) {
lines.push(
"",