Skip to content

feat(agent): configurable max retries and error desktop notifications#2998

Open
processtrader wants to merge 4 commits into
charmbracelet:mainfrom
processtrader:feat/max-retries-and-error-notifications
Open

feat(agent): configurable max retries and error desktop notifications#2998
processtrader wants to merge 4 commits into
charmbracelet:mainfrom
processtrader:feat/max-retries-and-error-notifications

Conversation

@processtrader

@processtrader processtrader commented May 24, 2026

Copy link
Copy Markdown

Summary

  • Configurable max retries: Adds a max_retries option to crush.json under options to control how many times provider requests are retried on transient failures. Defaults to the library's built-in default (2 retries) when unset.

  • Error desktop notifications: When the agent encounters an unrecoverable error (not a user cancel and not already handled specifically, e.g. Hyper auth), a desktop notification is now sent to alert the user. This is especially useful when a long-running request fails after all retry attempts are exhausted.

  • Improved network error display: When retries are exhausted due to network failures (connection reset, timeouts, etc.), the error is now shown as "Network Error" with a clean message like "connection reset by peer (retried 2 time(s))" instead of the raw Go error string.

  • Retry progress notifications: A desktop notification is now shown during each retry attempt, displaying the delay before the next attempt (e.g. "Retrying in 2s"). This gives users visibility into the retry process instead of silent failures.

Configuring max retries

Add to your crush.json:

{
  "options": {
    "max_retries": 5
  }
}
  • 0 or unset — uses the library default (2 retries, i.e. 3 total attempts)
  • 1 — one total attempt, no retries
  • 5 — up to 5 retries (6 total attempts)

Retries apply with exponential backoff and respect provider retry-after headers. Both the main agent and the agentic fetch sub-agent respect this setting.

Desktop notifications on error

When all retries are exhausted or an unrecoverable provider error occurs, the user receives a desktop notification:

Crush encountered an error — Agent failed in "session title"

This complements the existing Hyper re-authentication notification and only fires for non-interactive sessions where the user might not be actively watching the terminal. The detailed error message is always shown in the TUI.

Test plan

  • Set "max_retries": 1 in crush.json, provoke a transient provider error, verify no retry occurs
  • Set "max_retries": 0 or omit it, verify default retry behavior (2 retries)
  • Trigger an unrecoverable error, verify desktop notification appears
  • Cancel a request, verify no error notification is sent
  • Trigger a Hyper 401, verify re-auth notification (not generic error notification)
  • Trigger a network error (connection reset), verify "Network Error" title with retry count is shown
  • Observe retry in progress, verify desktop notification shows retry delay
  • Run go test ./internal/agent/ -run TestLastRetryableCause — all 5 sub-tests pass

💘 Generated with Crush

Assisted-by: Crush:glm-5.1

@processtrader processtrader force-pushed the feat/max-retries-and-error-notifications branch 3 times, most recently from 5338204 to 40142bd Compare June 6, 2026 08:00
…ions

Add `max_retries` option to crush.json for controlling provider request
retries, and send desktop notifications on unrecoverable agent errors.

💘 Generated with Crush

Assisted-by: Crush:glm-5.1
💘 Generated with Crush

Assisted-by: Crush:glm-5.1
RetryError.Unwrap() returns the last inner error, which is often a
ProviderError. errors.As(err, &providerErr) matched before the
RetryError branch, making the retry count display dead code. This
caused "Stream Transport Error — unexpected EOF" with no retry info
instead of "Network Error — unexpected EOF (retried N time(s))".

Order RetryError check first and extract ProviderError title/message
from the retry chain when present.

💘 Generated with Crush

Assisted-by: Crush:glm-5.1
@processtrader processtrader force-pushed the feat/max-retries-and-error-notifications branch from 40142bd to af67d20 Compare June 9, 2026 12:34
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.

1 participant