TUI sink discards actual error message in TurnFailed — user sees useless generic 'turn_failed (code=-32099)'
Description
When a turn fails internally (e.g. LLM API error, missing dependency), the TUI only shows error: turn_failed (code=-32099) — a generic catch-all message that provides zero diagnostic value to the user.
The actual error (the exception message captured as TurnFailed.error) is silently discarded by the TUI sink before it reaches the user.
Root Cause
In raven/tui_rpc/spine.py, the _make_tui_sink function handles TurnFailed events like this:
if isinstance(event, TurnFailed):
await _finish(event.conversation_id)
_drop(event.conversation_id)
if not event.cancelled:
await outlet.emit_error(event.conversation_id, _TURN_FAILED_CODE, "turn_failed", "internal")
It hardcodes the message "turn_failed" and ignores event.error — which contains the actual exception string from the scheduler (str(exc) at raven/spine/scheduler.py:280). The user sees a useless generic error instead of the real problem.
Example
On a missing orjson dependency (issue #113), the user got:
error: turn_failed (code=-32099)
While the actual error logged (inaccessible to the user) was:
Error calling LLM: litellm.APIConnectionError: APIConnectionError:
OpenAIException - No module named 'orjson'
Had event.error been shown, the user could have fixed it without reading source code.
Suggested Fix
Replace the hardcoded string with the actual error:
if not event.cancelled:
message = event.error or "turn_failed"
await outlet.emit_error(event.conversation_id, _TURN_FAILED_CODE, message, "internal")
This way the user sees the real error, e.g. error: No module named 'orjson' (code=-32099).
Related
- The TUI
ErrorEventpayload schema already has amessagefield — it's just never filled with useful content. - The Gateway's
GatewayTurnRunnermay have a similar issue in its error path (not checked).