Check that retried steps keep a conversation's requests append-only and drop request-scoped prompts
Merged
DO
1mo ago+311+311+012345678901234567890123456789-26-26-01234567890123456789
The append-only property test from #10552 never made the model retry. So prefix stability wasn't checked when a retried step meets append-mode instruction changes or request-scoped system prompts. This adds those conversations.
- Three retries, each continued in the second run from history after a JSON round trip (
ModelMessagesTypeAdapter), as an app that stores conversations would:- a tool that raises
ModelRetry, so its result isToolReturnPart(outcome='retried'); - text output that fails validation, so
RetryFeedbackPart(cause='validation_error')asks again; - an empty response, so
RetryFeedbackPart(cause='no_output')asks again.
- a tool that raises
- Each again with a request-scoped system prompt on every request: a capability enqueues
SystemPromptPart(scope='request')inbefore_model_request, the wayWarnNearLimitsdoes. - A new
request-scopecheck runs for every case in the matrix. It fails when a request-scoped prompt is still visible after the request it was for:- on the OpenAI APIs, when the next request sends it again;
- on Anthropic, which re-sends it with
clear_at: next_user_message, when no user message comes after it.
Results:
- All three retries keep the prefix append-only on Anthropic, OpenAI Responses and OpenAI Chat, including after the JSON round trip.
- With request-scoped prompts, the OpenAI APIs drop each one from the next request, retried steps included. That's listed in
ALLOWEDas a tail that drops exactly one request-scoped prompt per request. - One real break, filed as #10935 and fixed by #10938. On Anthropic, a
no_outputretry added only system-voice feedback, so the previous step's request-scoped prompt was never cleared and stayed visible to the retry. Since #10938 the retry leaves that prompt out, so Anthropic drops it from the tail like the OpenAI APIs, andretry:no-output-retry+request-scopedis anALLOWEDentry rather thanKNOWN.
It also gives DelegationReports a case of its own. It used to be exempt on the claim that SubAgents covers it, but no scenario delegated. In the new case:
- the parent delegates in the background;
- the child settles between the runs;
- the second run, continued from stored history, gets the report and makes one more request;
- the replays continue from that history.
The prefix stays append-only on all three providers. The report reaches history exactly once, which holds whatever shape the report takes (#10550 changes it).
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code