Skip to content

Conversation

@szmania
Copy link

@szmania szmania commented Jan 6, 2026

feat: Implement nested LLM retry configuration via --retries argument

This pull request refactors the LLM retry mechanism from individual top-level arguments into a structured, nested configuration object. This change improves configuration organization and aligns with other nested settings like agent-config.

Key Improvements:

  • Consolidated Configuration: Replaces the separate --retry-timeout, --retry-backoff-factor, and --retry-on-unavailable flags with a single --retries argument.
  • Flexible Input Formats: Supports both JSON strings via the command line and nested YAML structures in .cecli.conf.yml.
  • Enhanced Compatibility: The internal parser is designed to handle both hyphenated keys (e.g., backoff-factor) and underscore keys (e.g., retry_timeout), ensuring a seamless transition for users.
  • Robust Error Handling:
    • Implements exponential backoff using the configured factor.
    • Provides specific handling for ServiceUnavailableError, allowing users to opt-in to retries for this specific failure mode.
    • Intelligently skips retries for non-recoverable errors, such as exhausted resource RateLimitError (429).
  • Clean Architecture: Centralizes retry logic within the Model class initialization and the send_completion loop, reducing clutter in the main execution path.

Example Configuration (.cecli.conf.yml):

retries:
  retry-timeout: 30
  retry-backoff-factor: 1.50
  retry-on-unavailable: true

Implementation Details:

  • cecli/args.py: Added the --retries argument to the "Model settings" group.
  • cecli/main.py: Integrated convert_yaml_to_json_string to process the nested retry object from YAML/JSON.
  • cecli/models.py:
    • Updated Model.__init__ to parse the nested retries configuration with support for multiple key formats.
    • Implemented the retry loop in send_completion using asyncio.sleep and exponential backoff.
    • Restored the request_timeout property to maintain compatibility with existing tests.

Co-authored-by: aider-ce (openai/gemini_szmania/gemini-3-flash-preview)
@szmania szmania marked this pull request as draft January 6, 2026 07:05
Co-authored-by: aider-ce (openai/openai_gemini_cli/gemini-2.5-pro)
Co-authored-by: aider-ce (openai/openai_gemini_cli/gemini-2.5-pro)
@dwash96
Copy link
Owner

dwash96 commented Jan 17, 2026

How are we feeling on this one?

@szmania
Copy link
Author

szmania commented Jan 17, 2026

Just got to tiddy it up. Been a bit busy. Will try to take a look at it soon. If you want to knock it out if you have time, feel free too.

@szmania
Copy link
Author

szmania commented Jan 18, 2026

I've updated the PR description to reflect the final implementation details and the nested configuration structure. The logic now correctly handles the retries object from both CLI and YAML, including exponential backoff and specific handling for service unavailability. Ready for another look!

@dwash96 dwash96 changed the base branch from main to v0.90.6 January 18, 2026 03:17
@dwash96 dwash96 changed the base branch from v0.90.6 to v0.96.0 January 18, 2026 03:18
@dwash96
Copy link
Owner

dwash96 commented Jan 18, 2026

Nice, it's looking good to me! There are conflicts with 0.96.0 but I'll resolve this and add it in the version 🙏

@dwash96 dwash96 merged commit f01b6b0 into dwash96:v0.96.0 Jan 18, 2026
1 of 8 checks passed
@dwash96 dwash96 mentioned this pull request Jan 18, 2026
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