🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(agent): defer the init of sends that declare an LLM executor (#22848)
Arvin Xuef59b151122d
diff --git a/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts b/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.tsindex 749ee8dcb34..0b22a4a389d 100644--- a/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts+++ b/apps/server/src/services/aiAgent/__tests__/execAgent.deferredInit.test.ts@@ -402,6 +402,23 @@ describe('AiAgentService.runDeferredInit - parity with the send path', () => {});});+ // A web client inside the `agent_llm_relay` rollout declares an executor on+ // every send; the init never reads it (it rides on the pre-init state).+ it('defers a send whose client declares an LLM executor', async () => {+ const llmExecutor = {+ capabilities: ['llm_execute'],+ clientId: 'client-1',+ providers: ['ollama'],+ };++ await service.execAgent({ ...plainSend, llmExecutor } as any);++ expect(runOperationInit).not.toHaveBeenCalled();+ const created = mockCreateOperation.mock.calls[0][0];+ expect(created.pendingInitRequest).toBeDefined();+ expect(created.llmExecutor).toEqual(llmExecutor);+ });+it('keeps the init synchronous for a regenerate', async () => {rows.set('msg-prev-1', {content: 'earlier',diff --git a/apps/server/src/services/aiAgent/pipeline/deferInitGate.ts b/apps/server/src/services/aiAgent/pipeline/deferInitGate.tsindex 59679953f11..5bc7ba9181c 100644--- a/apps/server/src/services/aiAgent/pipeline/deferInitGate.ts+++ b/apps/server/src/services/aiAgent/pipeline/deferInitGate.ts@@ -12,7 +12,10 @@ export const isDeferredInitEnabled = async (userId: string): Promise<boolean> =>export interface DeferInitInput {/** Runs started without auto-start are stepped by their caller, not the queue. */autoStart: boolean;- /** Set for every caller that is not the plain composer (bots, group members, sub-agents, ...). */+ /**+ * Set for every caller that is not the plain composer (bots, group members, sub-agents, ...).+ * A client's LLM executor declaration is not one: the init never reads it.+ */hasOrchestration: boolean;queueRuntimeEnabled: boolean;request: AgentRunInitRequest;diff --git a/apps/server/src/services/aiAgent/pipeline/execTurn.ts b/apps/server/src/services/aiAgent/pipeline/execTurn.tsindex 3d5fc26fd07..f284c0987e0 100644--- a/apps/server/src/services/aiAgent/pipeline/execTurn.ts+++ b/apps/server/src/services/aiAgent/pipeline/execTurn.ts@@ -684,7 +684,6 @@ export const execAgentTurn = async (discordContext ||evalContext ||evalRuntime ||- params.llmExecutor ||params.reservedOperationId ||params.topicStartOwnerOperationId ||parentOperationId ||