Repository navigation
Commit 9d19eb5
fix(run): exit non-zero on session.error so CI wrappers see failures (#71)
The `aictrl run` command's session.error event handler logged the error
and accumulated it into a local string but never set `process.exitCode`.
On auth/provider failures, the subsequent `session.status: idle` broke
the run loop into the success branch and the process exited with code 0
— while stdout printed "Authentication Failed" or similar.
This silently broke CI workflows wrapping `aictrl run` (observed on
aictrl-dev/aictrl's "AI Review" workflow on 2026-05-20): step
conclusion `success`, no actual work, badge stays green.
Fix: set `process.exitCode = 1` when the session.error event fires for
the primary session. Sub-agent failures keep their existing behavior of
flowing into the parent agent. Use `exitCode` (not `process.exit`) so
the event loop drains naturally — session_complete still emits before
the process terminates.
Regression test (test/cli/run-session-error-exit.test.ts) statically
asserts the handler block sets a non-zero exit code, mirroring the
existing run-event-race.test.ts style.
Closes #70
Co-authored-by: Bulat Yapparov <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>1 parent ba8244f commit 9d19eb5
2 files changed
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
569 | 574 | | |
570 | 575 | | |
571 | 576 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments