Skip to content

[provider-openai] Response chaining sends previous_response_id AND full conversation history, double-counting server-side context #321

Description

@danshapiro

Summary

With enable_response_chaining: auto (the default behavior when the model supports reasoning), the OpenAI provider sends both previous_response_id and the full re-converted conversation history as input on each request. Server-side, the chained prior context is then counted in addition to the re-sent history, inflating effective context usage and accelerating context_length_exceeded failures (see #320 for the downstream failure mode).

Environment

  • Amplifier CLI: 2026.07.11-c150034
  • amplifier-core: 1.6.0
  • Provider: OpenAI (gpt-5.6-sol), enable_response_chaining: auto, enable_long_context: true

Details

In amplifier_module_provider_openai/__init__.py (current module cache):

  • At ~:1050-1053 and ~:1091-1092, when a chained response id is available the request still includes the full converted message history in input alongside previous_response_id.
  • The code itself acknowledges the double-count hazard for the continuation path at ~:1860-1864.

The azure-openai provider reuses OpenAIProvider and inherits the behavior.

Expected behavior

When previous_response_id is sent, input should contain only the delta (new messages since the chained response), or chaining should be disabled and full history sent — not both.

Actual behavior

Both are sent; server-side context consumption roughly doubles relative to the visible conversation, so overflow occurs well before the local token estimate predicts.

Suggested fix

  • When chaining is active, send only messages added since the last chained response.
  • Add a regression test asserting that a chained request's input excludes messages already covered by previous_response_id.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions