Error Handling
Agent-Level Errors
The directAgentRuntime result reports status; the host-facing AgentResult used by core reports finishReason.
Tool Errors
Tools should return errors as data rather than throwing. This lets the agent see the error and adjust:Mistake Limits
Core sessions can track consecutive recoverable mistakes and stop withfinishReason: "mistake_limit". Direct runtime runs report failure through status and error.
Loop Detection
Loop detection is available through core/session execution settings.Observability
OpenTelemetry Integration
The SDK integrates with OpenTelemetry for traces, metrics, and logs:agent_created— agent initialized with configtool_usage— tool called with name, duration, success/failuremodel_api_call— LLM API call with model, tokens, latencysession_ended— session completed with finish reason, total tokens

