diff --git a/e2e/perstack-cli/options.test.ts b/e2e/perstack-cli/options.test.ts index ffec484a..c1792d82 100644 --- a/e2e/perstack-cli/options.test.ts +++ b/e2e/perstack-cli/options.test.ts @@ -161,23 +161,31 @@ describe.concurrent("CLI Options", () => { }) describe.concurrent("CLI Options - Filter", () => { - /** Verifies --filter option with single type */ + /** Verifies --filter option with single type. + * Retries up to 3 times because --filter completeRun only outputs the final + * event; when the LLM call errors the runtime emits stopRunByError (blocked + * by the filter) and exits 0 with zero events. + */ it( "should filter events to only completeRun", async () => { - const cmdResult = await runCli( - [ - "run", - "--config", - GLOBAL_RUNTIME_CONFIG, - "--filter", - "completeRun", - "e2e-global-runtime", - "Say hello", - ], - { timeout: LLM_TIMEOUT }, - ) - const result = withEventParsing(cmdResult) + const args = [ + "run", + "--config", + GLOBAL_RUNTIME_CONFIG, + "--filter", + "completeRun", + "e2e-global-runtime", + "Say hello", + ] + let result = withEventParsing(await runCli(args, { timeout: LLM_TIMEOUT })) + for ( + let attempt = 1; + attempt < 3 && result.exitCode === 0 && result.events.length === 0; + attempt++ + ) { + result = withEventParsing(await runCli(args, { timeout: LLM_TIMEOUT })) + } expect(result.exitCode).toBe(0) // All events should be completeRun