Bind communication wakes to concrete inbox rows
Replace the worker's generic `"Continue."` default with a dispatch-time `initialUserTurn` that is resolved per trigger. Message and peer-request wakes now enumerate the actual unread messages (id, sender, channel, subject, reply-to) so the agent's first user turn carries the entities it is expected to act on, instead of idling into a status summary. Drop the system-prompt `heartbeatFallbackSection`: its "respond with a brief status summary" line fought the wake-reason block above it and was the main reason communication wakes degraded into self-narration. The wake-reason section plus the bound initial user turn now cover every case that section was carrying.
This commit is contained in:
1 parent
e917c614c9
commit
271c6cfec8
7 files changed
+152
-14
No files matched your search
@@ -13,6 +13,7 @@ import type { ConnectorId, ExecutionMode } from "@shared/types";
|
||||
import type { WorkspaceLockMode, EnqueueRunPayload } from "./types";
|
||||
import { normalizeCommentsForPrompt } from "../message-normalize";
|
||||
import { getConnectorModelPolicy, validateConnectorModelSelection } from "../connector-model-policy";
|
||||
import { resolveInitialUserTurn } from "./initial-user-turn";
|
||||
|
||||
export interface RunDispatchParams {
|
||||
runId: string;
|
||||
@@ -332,12 +333,15 @@ export function buildRunPayload(params: RunDispatchParams, deps: TurnContextDeps
|
||||
throw new Error(modelSelection.error);
|
||||
}
|
||||
|
||||
const initialUserTurn = resolveInitialUserTurn(
|
||||
{ trigger, task, companyId, agentId: agent.id },
|
||||
{ db },
|
||||
);
|
||||
|
||||
return {
|
||||
runId,
|
||||
companyId,
|
||||
taskId: task?.id ?? null,
|
||||
taskTitle: task?.title ?? "",
|
||||
taskDescription: task?.description ?? "",
|
||||
agentId: agent.id,
|
||||
agentName: agent.name,
|
||||
connectorId: connector.id,
|
||||
@@ -351,5 +355,6 @@ export function buildRunPayload(params: RunDispatchParams, deps: TurnContextDeps
|
||||
trigger,
|
||||
taskSessionId: taskSessionId ?? runId,
|
||||
executionMode: db.getCompanyExecutionMode(companyId) as "ai_ceo" | "ai_cofounder",
|
||||
initialUserTurn,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user