Repository navigation
fix(cli): exit non-zero when gaia chat --query or gaia stats fails - #4612
Conversation
A failed `gaia chat --query` exited 0 and printed a stray `1` to stdout, so `gaia chat -q ... && next-step` ran next-step after a failure. main() now treats an int returned by an action as the exit status instead of output, and the chat path's exception and Ctrl+C handlers return 1 and 130. `gaia stats` turned every backend error into "No stats available". The error now reaches main(), which prints the cause on stderr and exits 1; an empty result is reported as a normal "no stats yet" state with exit 0.
|
Verdict: Approve with suggestions Scripts can now trust One side effect isn't covered: Real-world evidenceN/A: the evidence stage produced no 🔍 Technical detailsIssues 🟢
🟢 Docs don't mention the new stderr hint (
Strengths
|
The answer has already printed by then; failing loudly is deliberate. The CLI reference now says so, and that gaia stats errors go to stderr.
…4675) Main's unit test lanes are red: `test_chat_query_success_exits_zero_without_printing_status` fails on Linux, macOS and Windows. amd#4520 made `gaia chat` call `agent._ensure_tool_loader_reset()` directly (no fallback), and amd#4612 added this test with a stub agent that lacks the method. Each passed on its own; main broke when both landed. The stub now has the method, as the other chat-path stubs already do. ## Test plan - [x] `pytest tests/unit/cli/test_cli_exit_codes.py` passes - [ ] `Unit Tests` green on main after merge Co-authored-by: Kalin Ovtcharov <[email protected]>
A failed
gaia chat --queryexited 0 and printed a stray1on stdout, sogaia chat -q "..." && next-stepran next-step after the agent failed.gaia statshid every backend error (for example, an unreachable Lemonade) behind "No stats available". Now a failed query exits 1 (130 on Ctrl+C) with nothing extra on stdout. A stats error prints its cause and exits 1. "No stats yet" is a normal empty state that exits 0.This touches only the chat block's two
excepthandlers, so it merges cleanly in either order with #4520.Test plan
pytest tests/unit/cli/test_cli_exit_codes.py: 8 tests run the realgaia.cli.mainentry point. 6 fail onmainand pass on this branch.pytest tests/unit/cli tests/unit/test_cli*.pywithGAIA_HOMEandGAIA_DAEMON_HOMEpointed at fresh temp dirs: 702 passed. The 4test_gaia_binary_on_pathcases pass once the venv'sbinis onPATH.cli.py(both--enable=E,W0201and the repo.pylintrcset).gaia stats; echo $?. It should print the connection error and1.