Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(orca): isolate queue-head recovery report ownership
david90b36aad747f
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerRuntime.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerRuntime.test.tsindex 1b38fb0894..e1ee6b1a8c 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerRuntime.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerRuntime.test.ts@@ -519,6 +519,11 @@ describe('orca remote worker runtime', () => {{ phase: 'dispatch preparation', projection: { autoResumePending: recoveryInfo, turnInProgress: true } },{ phase: 'vendor running after the idle snapshot', projection: { turnInProgress: true } },{ phase: 'usage reset wait', projection: { usageLimitWait: { resumeAt: 1_900_000_000_000 } } },+ { phase: 'queued retry waiting for usage reset', projection: {+ usageLimitWait: { resumeAt: 1_900_000_000_000 },+ recovery: { kind: 'queue-head', clientId: 'retry-1' },+ pendingQueue: [{ clientId: 'retry-1', retrySourceClientId: 'c-1' } as AgentInputProjection['pendingQueue'][number]],+ } },];it.each(recoveringProjections)('holds the dispatch during $phase and reports its recovered final once', async ({ projection }) => {const { runtime, deps, state } = setup({ history: [] });@@ -643,6 +648,33 @@ describe('orca remote worker runtime', () => {expect(deps.onTurnEnded).toHaveBeenCalledExactlyOnceWith('proxy-1', { status: 'done', finalText: 'Lead final' });});+ // PR #6787 / Orca contract 5a, unit: the active-turn case above misses a phone+ // input rejected before acceptance. pollNow must report the completed Lead input+ // once even while that unrelated queue head waits for its provider group quota.+ it.each([false, true])('reports a completed Lead reply while an unrelated queue head waits for quota (continuation=%s)', async continuation => {+ const { runtime, deps, state } = setup({ history: [] });+ await runtime.dispatch({ proxySessionId: 'proxy-1', rawContent: 'Lead task', clientId: 'c-1' });+ state.receipts['c-1'] = 'accepted';+ state.history = [+ { id: 'lead-input', clientId: 'c-1', role: 'user', content: 'Lead task' },+ { id: 'lead-final', role: 'assistant', content: 'Lead final' },+ ...(continuation ? [{ id: 'phone-input', clientId: 'phone-1', role: 'user' as const, content: 'Phone task' }] : []),+ ];+ const queued = continuation+ ? { clientId: 'phone-continue', autoResume: true, retrySourceClientId: 'phone-1' }+ : { clientId: 'phone-1' };+ state.inputProjection = {+ usageLimitWait: { resumeAt: 1_900_000_000_000 },+ recovery: { kind: 'queue-head', clientId: queued.clientId },+ pendingQueue: [queued as AgentInputProjection['pendingQueue'][number]],+ };+ await runtime.pollNow();+ await runtime.pollNow();+ expect(deps.onTurnEnded).toHaveBeenCalledExactlyOnceWith('proxy-1', { status: 'done', finalText: 'Lead final' });+ expect(deps.saveReport).toHaveBeenLastCalledWith('worker-1', null, 'lead-final');+ expect(runtime.hasPendingReport('proxy-1')).toBe(false);+ });+it('retains a new dispatch accepted while reading the previous reply', async () => {const { runtime, deps, state, invoke } = setup();await runtime.dispatch({ proxySessionId: 'proxy-1', rawContent: 'First task', clientId: 'c-1' });diff --git a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerRuntime.ts b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerRuntime.tsindex 19a478d950..551b3ed291 100644--- a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerRuntime.ts+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerRuntime.ts@@ -365,11 +365,17 @@ export function createOrcaRemoteWorkerRuntime(deps: OrcaRemoteWorkerRuntimeDeps)const sourceId = item.retrySourceClientId ?? item.supersedesUserClientId ?? item.clientId;return typeof sourceId !== 'string' || clientIds.includes(sourceId);};+ const pendingQueue = Array.isArray(projection?.pendingQueue) ? projection.pendingQueue : [];// An unrelated phone input's recovery must not hold an older completed Lead reply.const recovery = projection?.recovery;- const ownsRecovery = recovery?.kind !== 'active-turn' || ownsInput(recovery.item);- const pendingResume = Array.isArray(projection?.pendingQueue)- && projection.pendingQueue.some(item => item?.autoResume === true && ownsInput(item));+ let ownsRecovery = true;+ if (recovery?.kind === 'active-turn') {+ ownsRecovery = ownsInput(recovery.item);+ } else if (recovery?.kind === 'queue-head') {+ const queued = pendingQueue.find(item => item?.clientId === recovery.clientId);+ ownsRecovery = queued ? ownsInput(queued) : clientIds.includes(recovery.clientId);+ }+ const pendingResume = pendingQueue.some(item => item?.autoResume === true && ownsInput(item));return {states,// autoResumePending covers backoff and preparation; it is absent while thediff --git a/docs/dev-rules/orca-team-architecture.md b/docs/dev-rules/orca-team-architecture.mdindex 5f1478e0e5..12cff01982 100644--- a/docs/dev-rules/orca-team-architecture.md+++ b/docs/dev-rules/orca-team-architecture.md@@ -385,7 +385,8 @@ Worker turn 被 vendor 报终止型 error,但 interrupted-turn auto-resume 仍`turnInProgress`、`autoResumePending`、`usageLimitWait` 及队列里的隐藏 `autoResume` 输入。退避、排队或派发准备不能因 vendor 暂时空闲而回报进度、清除派活身份或累计缺少回复次数;历史读取后复核一次,若恢复已开始则丢弃该次候选和分页游标,待真正结束后从最新历史重读。-后续插话的恢复按 `retrySourceClientId` / 输入身份隔离;宿主放弃恢复后仍按原错误边界收尾。+后续插话的恢复按 `retrySourceClientId` / 输入身份隔离;`queue-head` 恢复先用 `clientId` 定位队列项,+再核对它的原始输入归属,不能用无关插话的额度等待挡住已完成的派活回报。宿主放弃恢复后仍按原错误边界收尾。旧端字段缺省保留兼容行为。回归见 `orcaRemoteWorkerRuntime.test.ts` 及`agent-input-coordinator.test.ts` 的真实协调器与轮询器组合用例。