Skip to content

[Bug]: ModelUtils retries auth/request-side errors when retryOn is unset, contradicting RETRYABLE_ERRORS docs #2861

Open

Description

@Letter2025

Summary

ModelUtils.applyTimeoutAndRetry(...) applies error -> true when ExecutionConfig.getRetryOn() is null:

if (retryOn == null) {
    retryOn = error -> true; // retry all errors by default
}

(agentscope-core/src/main/java/io/agentscope/core/model/ModelUtils.java, applyTimeoutAndRetry)

This contradicts the documented default of ExecutionConfig.RETRYABLE_ERRORS (which backs ExecutionConfig.MODEL_DEFAULTS): its javadoc explicitly lists HTTP 401/403 (authentication) and other 4xx client errors as non-retryable, while 429/5xx/timeout/network errors are retryable.

Because the field is nullable and ExecutionConfig.mergeConfigs keeps null when neither side supplies a predicate, any caller that builds an ExecutionConfig with only maxAttempts / backoff (or relies on the agent-level maxRetries budget) silently gets retry-all semantics: an invalid API key (401/403) or a permanently bad request (400/422) is retried maxAttempts - 1 extra times, each guaranteed to fail again — burning latency, quota, and log noise.

Impact

  • Every official model extension (OpenAI, Anthropic, DashScope, Gemini, Ollama) routes through ModelUtils.applyTimeoutAndRetry, so the bug affects all providers when retryOn is not explicitly configured.
  • Auth and request-side failures are retried pointlessly; the final error surfaces only after the full retry budget is exhausted.

Suggested Fix

When retryOn is null, default to ExecutionConfig.RETRYABLE_ERRORS (429/5xx/timeout/network) so runtime behavior matches the documented default. This is a behavior change for callers that relied on retry-all — it restores the semantics the docs already promise.

Related

  • [Bug]: ExecutionConfig retry settings are ignored for tool failures #2829 observes the tool-execution path also has a retry-default problem (ToolExecutor.applyRetry shares the same error -> true fallback); note that tool retry is currently dead code there because execute() converts failures into normal ToolResultBlock.error signals before retryWhen can see them. This issue fixes only the live model path; the tool path deserves separate tracking.

Activity

  1. oss-maintainer commented on Sep 14, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: bug | Area: area/core/model | Status: Confirmed (verified against current main)

    Root Cause: In ModelUtils.applyTimeoutAndRetry, when ExecutionConfig.getRetryOn() is null the default predicate becomes error -> true (retry everything). This contradicts the documented default ExecutionConfig.RETRYABLE_ERRORS, which excludes 401/403 and other 4xx client errors.
    Impact: Authentication / request-side errors burn the full retry budget (and backoff delays), masking the real failure and slowing failure detection.
    Severity: medium

    Suggested fix: default retryOn to RETRYABLE_ERRORS instead of retry-all when unset.


    Automated evaluation by github-manager-bot

  2. added
    area/core/model
    on Sep 14, 2026
  3. added a commit that references this issue on Oct 9, 2026
    94b7d63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/core/model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions