* fix(responses): refuse previous_response_id replay of turns stored redacted
With turn_off_message_logging on, spend logs keep only redacted-by-litellm
placeholders, so a bridged previous_response_id follow-up replayed them and the
model answered without the earlier turns. The bridge now answers 400 with
OpenAI's previous_response_not_found code, naming the id and asking for the
history in input, unless a compaction summary in the input replaces it
* fix(responses): import BadRequestError directly in the redacted replay refusal
The helper's return annotation read litellm.BadRequestError while litellm was still
initializing, so importing litellm on Python 3.12 failed with a circular import
* fix(responses): skip router fallbacks for the redacted replay refusal
A fallback deployment never holds the earlier turns either, so falling back only added a futile upstream call. Detection now also requires the blank prompt and input that redaction writes.
* test(integration): expect the redacted replay refusal in the custom logger redaction test
* fix(router): skip fallbacks for the redacted replay refusal in the rust core
* fix(router): keep the redacted replay refusal from cooling down or failing the deployment
A refused previous_response_id follow-up is the caller's stored history, not a deployment fault, so it now counts as declined: allowed_fails_policy never cools the deployment down for it and Prometheus no longer marks the deployment as an outage
* fix(responses): name previous_response_id on the input_tokens refusal for turns stored redacted
* fix(router): end retries for the redacted replay refusal in the rust core
* fix(responses): handle the redacted replay refusal like the unknown previous response refusal
PreviousResponseNotReplayableError now subclasses UnknownPreviousResponseError, so the router, cooldowns,
SDK retries, Slack alerts and background polling treat it the same way, and the per-consumer special
cases are gone. A follow-up that resends the earlier turns in input is no longer refused
* fix(responses): refuse a redacted replay read back from cold storage, and let fallbacks reach a provider that holds the response
The redacted turn check now reads the messages marker with empty input and prompt, which matches both the spend log row and the logging payload kept in cold storage. The refusal is built through previous_response_refusal, so a provider-held response id lets the fallback walk go on while a bridge-made id ends the call, the same as the not found refusal
* fix(responses): let only a restarted conversation past the redacted replay refusal
A follow-up on turns stored redacted went through whenever its input held any
assistant reply or tool call, so a partial resend still answered from placeholder
turns, and a tool loop got a 400 or a 200 depending on whether it echoed the call.
The refusal now passes input that starts with a user message ahead of its first
earlier reply, or that carries a compaction item
A conversation resent over redacted turns now replaces them the way a compaction
item does, so the provider no longer gets the placeholder turns ahead of it, and a
resent tool loop no longer fails at Anthropic on the replayed tool call
The message no longer blames message logging, since the redaction header stores
the same rows
* fix(responses): count resent replies per replayed turn and restart the replay at a stored resend
A follow-up on redacted turns now passes only when its input holds at least one earlier reply per replayed turn, so a few-shot example no longer stands in for a longer conversation. A stored turn that resent the conversation over redacted turns becomes the replay start, so its plain follow-ups replay from it, keeping earlier system and developer messages. A turn read back from cold storage keeps its conversation in `messages`, so the resend check and the replay read that when `input` is missing
* fix(responses): count the replies a stored resend already held when checking a later resend
After a stored turn resent the conversation over redacted turns, a later follow-up on a redacted turn passed as a resend with one reply per turn since that stored turn, so it could leave out the exchanges the stored turn resent. The count a resend must reach now starts from the replies that stored turn, or the first stored turn, already held
* fix(responses): ignore hosted items when counting resent replies and keep the stored input key on replay
A hosted tool search or reasoning item between two parts of one reply no longer splits it into two resent replies, so a resend that skips a redacted turn is refused instead of dropping that turn
A turn rebuilt from cold storage keeps its messages key when earlier instructions are merged into it, so its long tool calls are still renamed to the shortened name the provider was sent
---------
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>