Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix(agent-runtime): tag intervention continuations with the chat trigger (#19873)

YuTengjingc39a82f70d76
diff --git a/apps/server/src/routers/lambda/__tests__/aiAgent.heteroIntervention.test.ts b/apps/server/src/routers/lambda/__tests__/aiAgent.heteroIntervention.test.ts
index 91219c36902..8fbf7a2d24e 100644
--- a/apps/server/src/routers/lambda/__tests__/aiAgent.heteroIntervention.test.ts
+++ b/apps/server/src/routers/lambda/__tests__/aiAgent.heteroIntervention.test.ts
@@ -817,6 +817,8 @@ describe('aiAgentRouter β€” remote Human-in-the-loop', () => {
taskId: 'task-runtime',
}),
taskId: 'task-runtime',
+ // The continuation must keep the chat trigger so its LLM calls are not logged as unknown.
+ trigger: 'chat',
}),
);
expect(aiAgentService.repairInterventionContinuationTopicAnchor).toHaveBeenCalledWith(
@@ -873,6 +875,9 @@ describe('aiAgentRouter β€” remote Human-in-the-loop', () => {
).rejects.toThrow('durable completion failed');
expect(aiAgentService.execAgent).toHaveBeenCalledTimes(1);
+ expect(aiAgentService.execAgent).toHaveBeenCalledWith(
+ expect.objectContaining({ trigger: 'chat' }),
+ );
// Runtime dispatch already happened; releasing the claim here could let a
// second actor execute it again. The idempotent published hook is retried
// under the same resolutionRequestId instead.
diff --git a/apps/server/src/routers/lambda/aiAgent.ts b/apps/server/src/routers/lambda/aiAgent.ts
index b978cd8091c..d07a4a4e79c 100644
--- a/apps/server/src/routers/lambda/aiAgent.ts
+++ b/apps/server/src/routers/lambda/aiAgent.ts
@@ -513,6 +513,14 @@ const dispatchClaimedAgentIntervention = async (
}
if (dispatchProbe.state !== 'dispatched' && shouldDispatchRuntimeAction) {
+ /**
+ * A continuation is a fresh operation started by the user resolving an
+ * intervention, and the durable app context does not carry the parked
+ * run's trigger. Without an explicit trigger every LLM call in the
+ * continuation lands in route attempt logs with an unknown source.
+ */
+ const continuationTrigger = RequestTrigger.Chat;
+
switch (runtimeAction.type) {
case 'execute_custom_interaction': {
const customAction = runtimeAction.input.action;
@@ -555,6 +563,7 @@ const dispatchClaimedAgentIntervention = async (
toolCallId: runtimeAction.toolCallId,
},
topicStartReservationId: deterministicContinuationOperationId,
+ trigger: continuationTrigger,
});
}
break;
@@ -583,6 +592,7 @@ const dispatchClaimedAgentIntervention = async (
? { resumeApproval: singleDecision }
: { resumeApprovals: runtimeAction.decisions }),
topicStartReservationId: deterministicContinuationOperationId,
+ trigger: continuationTrigger,
});
break;
}
@@ -606,6 +616,7 @@ const dispatchClaimedAgentIntervention = async (
toolCallId: runtimeAction.toolCallId,
},
topicStartReservationId: deterministicContinuationOperationId,
+ trigger: continuationTrigger,
});
break;
}