🤯 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-runtime): queue steer follow-ups behind the newest live run (#21337)
Arvin Xua91104d7d3a6
diff --git a/apps/server/src/routers/lambda/__tests__/agentSteerQueue.test.ts b/apps/server/src/routers/lambda/__tests__/agentSteerQueue.test.tsindex 5264cf7dd75..7e0ce7d0f89 100644--- a/apps/server/src/routers/lambda/__tests__/agentSteerQueue.test.ts+++ b/apps/server/src/routers/lambda/__tests__/agentSteerQueue.test.ts@@ -205,14 +205,28 @@ describe('agentSteerQueueRouter.append', () => {});});- it('refuses to guess between two live runs on the same surface', async () => {- mocks.liveCandidates.mockReturnValue([{ id: 'op-1' }, { id: 'op-2' }]);+ // ROOT CAUSE:+ //+ // A run whose answer is done keeps its row `running` until its last step+ // commits, which took minutes. A follow-up typed behind the next run then saw+ // two live runs and was refused as ambiguous: the client kept it locally, the+ // run handed its turn back without answering, and the follow-up waited for+ // both runs to end.+ //+ // Before: two live runs refused the follow-up.+ // After: it queues behind the newest run, the one the user is looking at.+ it('queues behind the newest run while an older one still reads as live', async () => {+ mocks.liveCandidates.mockReturnValue([{ id: 'op-new' }, { id: 'op-old' }]);- await expect(caller().append(appendInput)).resolves.toEqual({- queued: false,- reason: 'ambiguous',+ await expect(caller().append(appendInput)).resolves.toMatchObject({+ queued: true,+ state: 'queued',});- expect(mocks.append).not.toHaveBeenCalled();+ expect(mocks.append).toHaveBeenCalledWith(+ { threadId: null, topicId: 'tpc-1', userId: 'user-1' },+ expect.objectContaining({ id: 'q-1' }),+ 'op-new',+ );});it('answers neither queued nor send-directly when the write outcome is unknown', async () => {diff --git a/apps/server/src/routers/lambda/agentSteerQueue.ts b/apps/server/src/routers/lambda/agentSteerQueue.tsindex 9ac7d5c2757..5c5b6cb549e 100644--- a/apps/server/src/routers/lambda/agentSteerQueue.ts+++ b/apps/server/src/routers/lambda/agentSteerQueue.ts@@ -110,8 +110,7 @@ export const agentSteerQueueRouter = router({** `queued: false` means nothing was stored and the client should send the* message itself: no own run is live (`idle`), the queue is at its bound- * (`full`), more than one own run is live on the surface (`ambiguous`), or- * the follow-up could not be stored (`unavailable`). A `SERVICE_UNAVAILABLE`+ * (`full`), or the follow-up could not be stored (`unavailable`). A `SERVICE_UNAVAILABLE`* error means the outcome is unknown: retry with the same `id`.*/append: steerQueueWriteProcedure.input(AppendSchema).mutation(async ({ input, ctx }) => {@@ -154,9 +153,10 @@ export const agentSteerQueueRouter = router({scope,);if (liveRuns.length === 0) return { queued: false as const, reason: 'idle' as const };- // Two runs on one surface (thread starts are not serialized): there is no- // telling which one the user is typing behind, so do not guess.- if (liveRuns.length > 1) return { queued: false as const, reason: 'ambiguous' as const };+ // More than one run can look live: a finished run keeps its row `running`+ // until its last step commits, and thread starts are not serialized. The+ // user types behind the newest one (the list is newest first); an older+ // run that ends later leaves entries bound to a live run alone.const [behindOperationId] = liveRuns;const entry: QueuedFollowUp = {