Class TurnContext

java.lang.Object
com.google.genkit.ai.agent.TurnContext

public final class TurnContext extends Object
Per-turn context exposed to TurnBody implementations. Carries the snapshot IDs reserved for this turn and the current turn index.
  • Constructor Details

    • TurnContext

      public TurnContext(String snapshotId, String parentSnapshotId, int turnIndex)
      Constructs a new TurnContext.
      Parameters:
      snapshotId - the snapshot ID reserved for this turn (empty string for client-managed)
      parentSnapshotId - the snapshot ID from the previous turn, or null if this is the first turn
      turnIndex - the zero-based index of this turn
  • Method Details

    • snapshotId

      public String snapshotId()
      Returns the snapshot ID reserved for this turn.
      Returns:
      the snapshot ID (empty string for client-managed mode)
    • parentSnapshotId

      public String parentSnapshotId()
      Returns the parent snapshot ID (ID of the previous turn's snapshot).
      Returns:
      the parent snapshot ID, or null if this is the first turn
    • turnIndex

      public int turnIndex()
      Returns the zero-based index of this turn.
      Returns:
      the turn index