Request errors
Inspectresponse.status and response.error for execution failures.
Catch AgentRequestError for transport or request failures.
Error context is optional. An absent HTTP status can indicate a local timeout, abort, or network failure.
Local and protocol errors
Invalid options or IDs can throwTypeError before a request starts.
Correct the argument instead of retrying it.
AgentProtocolError indicates an invalid snapshot, response identity, or stream envelope.
It can appear inside an AgentRequestError.cause chain.
Retrieve the response by its saved ID.
AgentEvent describes the transport envelope. agent.stream yields response views, not raw event objects.
Choose a recovery action
Rate limits and service failures
For429, reduce concurrent requests and avoid immediate retry loops.
For 5xx or network failures, allow time between attempts.
When retrying a submission, preserve its original idempotency key and body.
Correct validation or permission errors before retrying.