Skip to content

fix(cli): gracefully handle model API errors instead of crashing#42

Merged
MagicCube merged 1 commit into
MagicCube:mainfrom
c001estb0y:fix/graceful-model-error
May 21, 2026
Merged

fix(cli): gracefully handle model API errors instead of crashing#42
MagicCube merged 1 commit into
MagicCube:mainfrom
c001estb0y:fix/graceful-model-error

Conversation

@c001estb0y
Copy link
Copy Markdown
Contributor

Summary

  • When model provider returns 503/429/5xx, the error was re-thrown from the agent loop, crashing the Ink process
  • Now displays the error as an assistant message so the user can retry without restarting

Reproduce

  1. Configure a model that returns 503 (e.g. DeepSeek during peak hours)
  2. Send any message
  3. Before: process exits with unhandled error
  4. After: shows "Error: ..." message, user can continue

Change

src/cli/tui/hooks/use-agent-loop.ts — 1 line removed, 6 lines added

When the model provider returns 503/429/5xx, the error was re-thrown
from the agent loop hook, causing the Ink process to crash and exit.

Now the error is caught and displayed as an assistant message so the
user can retry without restarting the session.
Copy link
Copy Markdown
Owner

@MagicCube MagicCube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MagicCube MagicCube merged commit 5cc1fb3 into MagicCube:main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants