Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Extends the @dynamic token syntax for Retry-After headers to accept an optional initial value (@dynamic=N), enabling per-response retry-after configuration instead of relying solely on the global retryAfterInSeconds setting.

Changes

  • Parse @dynamic=value syntax in UpdateProxyResponse, falling back to global config for plain @dynamic
  • Made ShouldThrottle static with explicit retryAfterInSeconds parameter, captured via lambda for per-response values
  • Added warning log for invalid @dynamic= values (non-integer)

Example

{
  "statusCode": 429,
  "headers": [
    {
      "name": "Retry-After",
      "value": "@dynamic=17"
    }
  ],
  "body": {
    "error": {
      "message": "Rate limit exceeded. Wait 17 seconds."
    }
  }
}

Uses 17 seconds for this response regardless of the plugin's global retryAfterInSeconds setting.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature: Support @dynamic=initialvalue for configurable initial retry-after value in GenericRandomErrorPlugin responses</issue_title>
<issue_description>## Proposal

Extend the GenericRandomErrorPlugin to enhance the handling of the retry-after response header. Currently, the initial value for retry-after is set globally for all responses in the plugin's configuration. This feature proposes supporting a syntax of @dynamic=initialvalue within the response header, enabling the initial retry-after value to be set on a per-response basis.

Motivation

  • Allows greater flexibility and realism when simulating errors with varying backoff requirements.
  • Developers can configure different endpoints to return different initial retry-after values, improving test coverage for clients handling these scenarios.

Acceptance Criteria

  • The plugin should parse the @dynamic=initialvalue syntax from the retry-after response header configuration.
  • If present, the initial retry-after value for that response should override the global default for that invocation.
  • Documentation should be updated with usage examples.

Example

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.29.0/genericrandomerrorplugin.errorsfile.schema.json",
  "errors": [
    {
      "request": {
        "url": "https://models.github.ai/inference/chat/completions",
        "method": "POST"
      },
      "responses": [
        {          
          "statusCode": 429,
          "headers": [
            {
              "name": "Content-Type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "Retry-After",
              "value": "@dynamic=17"
            }
          ],
          "body": {
            "error": {
              "code": "RateLimitReached",
              "message": "Rate limit of 15 per 60s exceeded for UserByModelByMinute. Please wait 17 seconds before retrying.",
              "details": "Rate limit of 15 per 60s exceeded for UserByModelByMinute. Please wait 17 seconds before retrying."
            }
          }
        }
      ]
    }
  ]
}

In this example, the initial retry-after value will be set to 17 for this response, regardless of the global plugin setting.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@garrytrinder Good idea! 👍

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 19, 2026 12:00
…ial values

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
…y variable usage

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for dynamic initial retry-after value in plugin Support @dynamic=initialvalue for per-response retry-after values in GenericRandomErrorPlugin Jan 19, 2026
Copilot AI requested a review from waldekmastykarz January 19, 2026 12:06
@waldekmastykarz waldekmastykarz marked this pull request as ready for review January 19, 2026 12:09
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner January 19, 2026 12:09
Copilot AI review requested due to automatic review settings January 19, 2026 12:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the GenericRandomErrorPlugin to support per-response retry-after values using the @dynamic=N syntax in response headers. This allows developers to configure different initial retry-after values for individual error responses instead of relying solely on the global retryAfterInSeconds configuration setting.

Changes:

  • Enhanced header value parsing to support @dynamic=value syntax with fallback to global config for plain @dynamic
  • Refactored ShouldThrottle method to be static with explicit retry-after parameter, captured via lambda for per-response values
  • Added warning logging for invalid @dynamic= values

@garrytrinder garrytrinder self-assigned this Jan 20, 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.

Feature: Support @dynamic=initialvalue for configurable initial retry-after value in GenericRandomErrorPlugin responses

3 participants