Skip to content

previous_response_id stateful chain support #21

@HXYerror

Description

@HXYerror

Part of #1. Depends on #3.

Goal

OpenAI's Responses API supports two ways to carry context across turns:

  1. Stateless: the client echoes prior reasoning items (with encrypted_content) into input (covered by Model-to-endpoint routing (chat vs responses) #5)
  2. Stateful: the client passes previous_response_id: \"resp_…\" and only sends the new user turn; the server reconstitutes the prior context

We should support both. (1) is the path Codex CLI prefers for ZDR; (2) is what some lighter Responses clients use.

Current state

previous_response_id is unmentioned anywhere in the repo (Grep 0 hits, see #1 audit).

Tasks

  • Add previous_response_id?: string to the request type (Add upstream Responses API service client #3)
  • Pass it through to upstream verbatim — copilot-api does not need to maintain its own state store; Copilot upstream handles it
  • Add id: string (the response id) to the response type if not already there from Add upstream Responses API service client #3
  • Document in the README that both stateful and stateless multi-turn modes work
  • (Optional, future) If Copilot upstream's state retention turns out to differ from OpenAI's (e.g., shorter TTL, different store semantics), surface that in docs

Acceptance criteria

  • Two-turn test: turn 1 returns id: \"resp_X\". Turn 2 sends only the new user message + previous_response_id: \"resp_X\". Reply correctly references context from turn 1.

File pointers

Metadata

Metadata

Assignees

No one assigned

    Labels

    reasoningReasoning / thinking / encrypted_contentresponses-apiOpenAI /v1/responses API support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions