mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:16:05 +00:00
Preserve turn lineage across goal continuations (#41562)
## Why Automatic goal continuations should remain attributable to the turn that created the goal. External input, hook context, or goal edits can make that attribution ambiguous and must not leave stale lineage metadata behind. ## What changed - Carry the trusted root and previous parent turn through successive automatic goal continuations. - Invalidate stored lineage when external context reaches an active turn or when a goal is edited or cleared. - Preserve lineage for async hook results only when they belong to the receiving turn. ## Testing - Cover goal continuations across intervening user turns and external objective edits. - Cover active, buffered, and externally injected hook or response context. GitOrigin-RevId: 22ccc07961cd0ed8f4b17912b7efa416b342bf50
This commit is contained in:
1 parent
6478a751fd
commit
4210c08def
9 files changed
+410
-10
No files matched your search
@@ -510,6 +510,28 @@ impl CodexThread {
|
||||
self.session.inject_if_running(items).await
|
||||
}
|
||||
|
||||
/// Returns the trusted root when the expected turn is currently active.
|
||||
pub async fn active_turn_root(&self, expected_turn_id: &str) -> Option<String> {
|
||||
let active = self.session.active_turn.lock().await;
|
||||
let task = active.as_ref()?.task.as_ref()?;
|
||||
if task.turn_context.sub_id != expected_turn_id {
|
||||
return None;
|
||||
}
|
||||
task.turn_context.turn_metadata_state.root_turn_id()
|
||||
}
|
||||
|
||||
/// Invalidates the trusted root when the expected turn is currently active.
|
||||
pub async fn invalidate_turn_lineage(&self, expected_turn_id: &str) {
|
||||
let active = self.session.active_turn.lock().await;
|
||||
if let Some(task) = active.as_ref().and_then(|turn| turn.task.as_ref())
|
||||
&& task.turn_context.sub_id == expected_turn_id
|
||||
{
|
||||
task.turn_context
|
||||
.turn_metadata_state
|
||||
.mark_root_turn_ambiguous();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn set_app_server_client_info(
|
||||
&self,
|
||||
app_server_client_name: Option<String>,
|
||||
|
||||
Reference in new issue
Block a user