Problem
Currently, all stages created via Choice.create_stage() are flat — there is no way to express a parent-child relationship between stages. This limits the ability to represent structured, hierarchical reasoning or multi-step workflows in the response UI.
Proposed solution
Add a parent parameter to Choice.create_stage() that accepts an existing Stage instance. When provided, the resulting StartStageChunk will include a parent_stage_index field in the wire format, allowing clients to render stages as a tree.
parent = choice.create_stage("Planning")
child = choice.create_stage("Step 1", parent=parent)
The parent_stage_index field is omitted from the wire format when not set, preserving backwards compatibility.
Changes required
Choice.create_stage(name, *, parent: Stage | None = None)
Stage.stage_index property (public read access to the stage index)
StartStageChunk.parent_stage_index: int | None field
Problem
Currently, all stages created via
Choice.create_stage()are flat — there is no way to express a parent-child relationship between stages. This limits the ability to represent structured, hierarchical reasoning or multi-step workflows in the response UI.Proposed solution
Add a
parentparameter toChoice.create_stage()that accepts an existingStageinstance. When provided, the resultingStartStageChunkwill include aparent_stage_indexfield in the wire format, allowing clients to render stages as a tree.The
parent_stage_indexfield is omitted from the wire format when not set, preserving backwards compatibility.Changes required
Choice.create_stage(name, *, parent: Stage | None = None)Stage.stage_indexproperty (public read access to the stage index)StartStageChunk.parent_stage_index: int | Nonefield