Error Handling
Tool failures
Section titled “Tool failures”Tools return ToolResult.Success(...) or ToolResult.Error(...). Tool failures are still part of the event stream, so you can inspect and react before deciding whether to continue.
Turn boundaries
Section titled “Turn boundaries”When using StepAsync(), inspect TurnResult:
FinishReasontells you why the turn stopped.ToolCallsshows the requested tool executions.RequiresNextTurntells you whether the loop should continue.
Max token handling
Section titled “Max token handling”Agent exposes ContinueOnMaxTokens. Leave it off for bounded work or turn it on for long-form generation that should continue past one max-token boundary.
Timeouts and retry strategy
Section titled “Timeouts and retry strategy”ToolTimeoutcaps tool execution time.SessionHelpers.RemoveFailedTools(...)andRewind(...)help recover from failed branches.CreateCheckpoint(...)is useful before risky operations.
Interactive recovery
Section titled “Interactive recovery”If a workflow needs a human decision, pair StepAsync() with tool inspection or use interactive tooling through IToolContextProvider and AskUserQuestion.