mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Expose and persist turn lineage across the app server (#51415)
## Why Clients starting delegated work need to attribute descendant turns to the original turn and retain that attribution through completion and history reads. ## What changed - Accept optional `parentTurnId` and `rootTurnId` in `turn/start`, and expose `rootTurnId` on returned turns and lifecycle notifications. - Default new turns to their own root when none is supplied. Preserve the active turn's root when steering, ignoring incoming lineage fields. - Carry root IDs through completion, interruption, recovery, and fork boundaries, and persist them for paginated history reads. Leave unknown roots null in older history. - Update protocol schemas and generated TypeScript and Python bindings. ## Testing Extend coverage for default and explicit roots, steering without changing lineage, interrupted and recovered turns, history reads after restart in both history modes, nested fork pagination, and compatibility with older database writers. GitOrigin-RevId: f1a570a12bd11742929fd2e8b017e5d35aa07dcb
This commit is contained in:
@@ -85,7 +85,7 @@ impl AgentRunner {
|
||||
)
|
||||
.await?
|
||||
{
|
||||
StartIfIdleSubmission::Started { turn_id } => turn_id,
|
||||
StartIfIdleSubmission::Started { turn_id, .. } => turn_id,
|
||||
StartIfIdleSubmission::NotSubmitted { reason } => {
|
||||
return Err(CodexErr::InvalidRequest(format!(
|
||||
"agent prompt was not submitted: {reason:?}"
|
||||
|
||||
@@ -485,7 +485,7 @@ impl GoalRuntimeHandle {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(StartIfIdleSubmission::Started { turn_id }) => {
|
||||
Ok(StartIfIdleSubmission::Started { turn_id, .. }) => {
|
||||
// Turn-stop evaluation takes the same permit, so even a fast response
|
||||
// cannot finish before this host-admitted continuation is identified.
|
||||
self.inner.accounting_state.mark_goal_continuation(turn_id);
|
||||
|
||||
@@ -43,7 +43,7 @@ pub async fn start_review_turn(
|
||||
match crate::run_before_review_deadline(deadline, external_cancel, runtime.submit_turn(request))
|
||||
.await?
|
||||
{
|
||||
Ok(TurnInputSubmission::Started { turn_id }) => Ok(turn_id),
|
||||
Ok(TurnInputSubmission::Started { turn_id, .. }) => Ok(turn_id),
|
||||
result => Err(GuardianReviewSessionOutcome::SessionFailed {
|
||||
error: match result {
|
||||
Ok(submission) => anyhow!("guardian review input was not started: {submission:?}"),
|
||||
|
||||
@@ -393,7 +393,7 @@ async fn starting_a_selected_item_preserves_the_remaining_queue() -> anyhow::Res
|
||||
|
||||
assert!(matches!(
|
||||
submission,
|
||||
StartIfIdleSubmission::Started { turn_id } if !turn_id.is_empty()
|
||||
StartIfIdleSubmission::Started { turn_id, .. } if !turn_id.is_empty()
|
||||
));
|
||||
assert_eq!(vec![first], service.list(thread_id).await?);
|
||||
wait_for_event_match(test.codex.as_ref(), |event| match event {
|
||||
|
||||
Reference in New Issue
Block a user