mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve acceptance order in retained thread context (#42770)
## Why Queued prompts and `request_user_input` answers can be persisted in a different order from when the host accepted them. Using persistence order can therefore reorder retained instructions during replay or apply the wrong rollback boundary. ## What changed - Reserve an acceptance sequence for user prompts and elicitation responses when retained thread context is enabled. - Persist that sequence with user-message metadata and verified answers, and use it when ordering, bounding, replaying, and rolling back retained context. - Keep events without acceptance metadata compatible with legacy recording order. ## Testing - Cover delayed queued-input recording, rejected prompts, checkpoint replay, compaction, rollback migration, and legacy retained-context behavior. GitOrigin-RevId: 42d24465cc2033bc51c0c2da79d3c0884a8ad98a
This commit is contained in:
1 parent
88f87d907a
commit
99d66aa1c5
24 files changed
+489
-152
No files matched your search
@@ -85,7 +85,7 @@ impl RequestUserInputHandler {
|
||||
auto_resolution_ms: None,
|
||||
};
|
||||
let questions = args.questions.clone();
|
||||
let response = session
|
||||
let accepted = session
|
||||
.request_user_input(turn.as_ref(), call_id.clone(), args)
|
||||
.await
|
||||
.ok_or_else(|| {
|
||||
@@ -94,6 +94,8 @@ impl RequestUserInputHandler {
|
||||
))
|
||||
})?;
|
||||
|
||||
let response = accepted.response;
|
||||
|
||||
let content = serde_json::to_string(&response).map_err(|err| {
|
||||
FunctionCallError::Fatal(format!(
|
||||
"failed to serialize {REQUEST_USER_INPUT_TOOL_NAME} response: {err}"
|
||||
@@ -142,11 +144,14 @@ impl RequestUserInputHandler {
|
||||
.collect::<Vec<_>>();
|
||||
if !user_input.is_empty() {
|
||||
session
|
||||
.record_retained_context(RetainedContextEvent::VerifiedAnswer(VerifiedAnswer {
|
||||
turn_id: turn.sub_id.clone(),
|
||||
call_id,
|
||||
questions: user_input,
|
||||
}))
|
||||
.record_retained_context(RetainedContextEvent::VerifiedAnswer {
|
||||
answer: VerifiedAnswer {
|
||||
turn_id: turn.sub_id.clone(),
|
||||
call_id,
|
||||
questions: user_input,
|
||||
},
|
||||
acceptance_order: accepted.acceptance_order,
|
||||
})
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user