fix: use previous_response_id chaining for OpenAI store=true follow-ups (#23450)

OpenAI Responses follow-up turns were replaying full assistant/tool
history even when `store=true`, which breaks after reasoning +
provider-executed `web_search` output.

This change persists the OpenAI response ID on assistant messages, then
in `coderd/x/chatd` switches `store=true` follow-ups to
`previous_response_id` chaining with a system + new-user-only prompt.
`store=false` and missing-ID cases still fall back to manual replay.

It also updates the fake OpenAI server and integration coverage for the
chaining contract, and carries the rebased path move to `coderd/x/chatd`
plus the migration renumber needed after rebasing onto `main`.
This commit is contained in:
Michael Suchacz
2026-03-24 14:57:40 +01:00
committed by GitHub
parent b9f0c479ac
commit 02356c61f6
12 changed files with 935 additions and 93 deletions
+4 -2
View File
@@ -241,7 +241,8 @@ INSERT INTO chat_messages (
context_limit,
compressed,
total_cost_micros,
runtime_ms
runtime_ms,
provider_response_id
)
SELECT
@chat_id::uuid,
@@ -260,7 +261,8 @@ SELECT
NULLIF(UNNEST(@context_limit::bigint[]), 0),
UNNEST(@compressed::boolean[]),
NULLIF(UNNEST(@total_cost_micros::bigint[]), 0),
NULLIF(UNNEST(@runtime_ms::bigint[]), 0)
NULLIF(UNNEST(@runtime_ms::bigint[]), 0),
NULLIF(UNNEST(@provider_response_id::text[]), '')
RETURNING
*;