Skip to content

Support sub-stages (hierarchical stages) in Chat Completion responses #444

Description

@korotaav48

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions