pub struct SessionTurnState {
pub tool_calls: HashMap<String, ToolCall>,
pub task_tool_use_ids: HashMap<String, String>,
pub model_id: String,
pub requested_model_id: Option<String>,
pub resolved_runtime_model_id: Option<String>,
pub mode: Option<PermissionMode>,
pub supported_mode_ids: Vec<PermissionMode>,
pub runtime_unavailable_mode_ids: Vec<PermissionMode>,
pub mode_state: Option<ModeState>,
pub agents_emitted_this_turn: bool,
pub last_assistant_error: Option<String>,
}Expand description
Per-session SDK turn state - model-resolution cache, mode
capability state, MCP per-server cooldowns, and the auth/error
flags that survive across messages. Held authoritatively by
forge-workspace; a view projects from there.
Fields§
§tool_calls: HashMap<String, ToolCall>Live tool-call store keyed by tool_use_id for cross-message
tool_use ↔ tool_result pairing.
task_tool_use_ids: HashMap<String, String>Maps task-tool task_id → tool_use_id so TaskProgress /
TaskNotification messages can resolve back to the originating
tool call for ToolCallUpdate emission.
model_id: StringRaw model id from the CLI’s session-init payload.
requested_model_id: Option<String>Model id explicitly requested via /model.
resolved_runtime_model_id: Option<String>Resolved model id after runtime fallback from the requested id.
mode: Option<PermissionMode>Active permission mode (typed enum, not the wire string).
Populated from System(init).permissionMode and the SetMode
command path.
supported_mode_ids: Vec<PermissionMode>Permission modes the runtime currently supports.
Permission modes recognised but currently unavailable.
mode_state: Option<ModeState>Current mode resolution alongside the human-readable label.
agents_emitted_this_turn: boolWhether the agents catalogue has been emitted for this turn. The first
system/init of a turn carries it; subsequent re-fires within the same
turn are no-ops.
last_assistant_error: Option<String>Last assistant error subtype seen on the wire - survives
across messages so a subsequent Result can classify the
turn correctly.