diff --git a/src/main/runtime/runtime-rpc-long-poll-transport.test.ts b/src/main/runtime/runtime-rpc-long-poll-transport.test.ts index c17e045b466..c23b4e6b28b 100644 --- a/src/main/runtime/runtime-rpc-long-poll-transport.test.ts +++ b/src/main/runtime/runtime-rpc-long-poll-transport.test.ts @@ -44,6 +44,25 @@ describe('OrcaRuntimeRpcServer', () => { ).toBe('wait') }) + it.each(['agent.launch', 'agent.launchReplay'])( + 'keeps a prompted %s alive while it waits for the agent to be ready', + (method) => { + const prompt = { text: 'fix the build', delivery: 'submit' } + expect( + classifyRuntimeLongPoll({ + id: 'req_launch', + authToken: 'token', + method, + params: { prompt } + }) + ).toBe('wait') + // Without a prompt nothing waits on the agent, so the launch stays a short call. + expect( + classifyRuntimeLongPoll({ id: 'req_launch', authToken: 'token', method, params: {} }) + ).toBeNull() + } + ) + it('keeps agent-prompt submission sockets alive during verification', () => { expect( classifyRuntimeLongPoll({ diff --git a/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts b/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts index 02d8422547e..c1ddeb78a6e 100644 --- a/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts +++ b/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts @@ -26,6 +26,17 @@ export function classifyRuntimeLongPoll(request: RpcRequest): RuntimeLongPollCla if (request.method === 'orchestration.workerStart') { return 'wait' } + // A launch with a prompt waits for the agent's readiness before writing it, up to 60 s, and a + // reply lost to the 30 s idle timer reads as a dead runtime instead of an undelivered prompt. + if ( + (request.method === 'agent.launch' || request.method === 'agent.launchReplay') && + typeof request.params === 'object' && + request.params !== null && + 'prompt' in request.params && + request.params.prompt !== undefined + ) { + return 'wait' + } if (request.method === 'browser.clientHost.attach') { return 'browser-host' }