From d25d71b595e56fd4e3bc2db09ff7ea22368de1c3 Mon Sep 17 00:00:00 2001 From: Aamer Akhter Date: Sat, 24 Oct 2026 20:45:00 -0400 Subject: [PATCH] fix(agent): COD-549 report readiness failures with empty errors --- src/cli-agent.ts | 2 +- test/cli-agent.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cli-agent.ts b/src/cli-agent.ts index ac96664b..fc3fec03 100644 --- a/src/cli-agent.ts +++ b/src/cli-agent.ts @@ -573,7 +573,7 @@ export async function agentSpawn(deps: AgentDeps, options: SpawnOptions): Promis ready = !dead && Boolean(result?.matched); } } catch (error) { - readinessError = getErrorMessage(error); + readinessError = getErrorMessage(error) || 'Readiness request failed'; } } diff --git a/test/cli-agent.test.ts b/test/cli-agent.test.ts index 60454991..ff41f7ce 100644 --- a/test/cli-agent.test.ts +++ b/test/cli-agent.test.ts @@ -577,6 +577,21 @@ describe('agent spawn', () => { { method: 'GET', path: `/api/v1/sessions/${OTHER}/wait-output` }, ]); }); + + it.each([ + { error: new Error(''), kind: 'Error' }, + { error: '', kind: 'string' }, + ])('reports a readiness failure when the thrown $kind has no message', async ({ error }) => { + const deps = fakeDeps((options) => { + if (options.path === '/api/v1/quick-start') return ok({ sessionId: OTHER }); + throw error; + }, true); + + expect(await agentSpawn(deps, { caseName: 'c', mode: 'claude', ready: true, timeoutMs: 1000 })).toBe(EXIT.error); + expect(deps.out).toHaveLength(1); + expect(JSON.parse(deps.out[0])).toEqual({ sessionId: OTHER, readinessError: 'Readiness request failed' }); + expect(deps.calls).toHaveLength(2); + }); }); describe('session id prefixes', () => {