Skip to content

TurnOptions

Configuration for the agent loop’s turn() function. Controls iteration limits, retry policy, context management, and execution behavior.

Runtimes accept these as either a TurnOptions object or individual keyword/named parameters — the TypeSpec model defines the canonical field set.

---
title: TurnOptions
config:
  look: handDrawn
  theme: colorful
  class:
    hideEmptyMembersBox: true
---
classDiagram
    class TurnOptions {
        +int32 maxIterations
        +int32 maxLlmRetries
        +int32 contextBudget
        +boolean parallelToolCalls
        +boolean raw
        +int32 turn
        +CompactionConfig compaction
    }
    class CompactionConfig {
        +string strategy
        +int32 budget
        +dictionary options
    }
    TurnOptions *-- CompactionConfig
maxIterations: 10
maxLlmRetries: 3
contextBudget: 100000
parallelToolCalls: true
raw: false
turn: 1
compaction:
strategy: summarize
NameTypeDescription
maxIterationsint32Maximum number of tool-call iterations before the loop terminates
maxLlmRetriesint32Maximum number of LLM call retries on transient failure within a single iteration
contextBudgetint32Character budget for the context window. When set, the loop trims older messages to stay within budget before each LLM call. System messages are never dropped.
parallelToolCallsbooleanWhether to execute multiple tool calls concurrently when the LLM returns several in one response
rawbooleanWhen true, return the raw LLM response without processor post-processing
turnint32Turn number for trace labeling. Useful when the caller maintains an outer conversation loop.
compactionCompactionConfigContext compaction configuration. Controls how messages are summarized when the context window exceeds the budget.

The following types are composed within TurnOptions: