mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58: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:
@@ -11672,6 +11672,13 @@ class Turn(BaseModel):
|
||||
description="Describes how much of `items` has been loaded for this turn.",
|
||||
),
|
||||
] = "full"
|
||||
root_turn_id: Annotated[
|
||||
str | None,
|
||||
Field(
|
||||
alias="rootTurnId",
|
||||
description="ID of the first turn in the chain of work that led to this turn. Pass this as `rootTurnId` when starting work on behalf of this turn. May be null in older history or a `review/start` response.",
|
||||
),
|
||||
] = None
|
||||
started_at: Annotated[
|
||||
int | None,
|
||||
Field(alias="startedAt", description="Unix timestamp (in seconds) when the turn started."),
|
||||
@@ -12555,12 +12562,26 @@ class TurnStartParams(BaseModel):
|
||||
description="Optional JSON Schema used to constrain the final assistant message for this turn.",
|
||||
),
|
||||
] = None
|
||||
parent_turn_id: Annotated[
|
||||
str | None,
|
||||
Field(
|
||||
alias="parentTurnId",
|
||||
description="ID of the turn that caused this new turn to start.\n\nSet this when starting work on behalf of another turn, such as delegated work in a different thread. Leave unset for work started directly by the user. Ignored when this request adds input to an active turn.",
|
||||
),
|
||||
] = None
|
||||
personality: Annotated[
|
||||
Personality | None,
|
||||
Field(
|
||||
description="@deprecated `friendly` and `pragmatic` no longer select a style. Changing this does not rewrite the thread's existing instructions."
|
||||
),
|
||||
] = None
|
||||
root_turn_id: Annotated[
|
||||
str | None,
|
||||
Field(
|
||||
alias="rootTurnId",
|
||||
description="ID of the first turn in the chain of work that led to this new turn.\n\nWhen setting `parentTurnId`, set this to the parent turn's `rootTurnId` when known. This keeps descendant work attributed to the original turn. If omitted, the new turn becomes its own root. Ignored when this request adds input to an active turn.",
|
||||
),
|
||||
] = None
|
||||
sandbox_policy: Annotated[
|
||||
SandboxPolicy | None,
|
||||
Field(
|
||||
|
||||
Reference in New Issue
Block a user