Daita agents / guide
Error Handling
Handle normalized Daita failures without parsing messages or depending on provider exceptions.
#Stable Error Metadata
Normalized runtime failures derive from DaitaError in daita.errors. Every normalized error carries:
error_code: a stable snake-case identifier;retryability:unknown,transient,retryable, orpermanent;retry_hint: the string form of retryability; andis_transient(),is_retryable(), andis_permanent()helpers.
from daita.errors import DaitaError
try:
result = await agent.run("Summarize orders")
except DaitaError as error:
logger.warning(
"Daita failed",
extra={
"error_code": error.error_code,
"retryability": error.retryability.value,
},
)
if error.is_retryable():
schedule_bounded_retry()
else:
raiseDo not decide retry behavior by parsing human-readable messages.
#Public Categories
| Error | Scope |
|---|---|
AgentError | Agent lifecycle or operation failure |
ConfigError | Invalid or unavailable configuration; permanent |
AuthenticationError | Missing or rejected credentials |
LLMError | Provider-neutral model or routing failure |
RateLimitError | Provider throttling with optional retry metadata |
ValidationError | Invalid runtime data at a public boundary |
SkillError | Skill discovery, validation, or lifecycle failure |
TransientError | Temporary failure that may clear unchanged |
RetryableError | A bounded retry or alternate route may succeed |
PermanentError | The input or configuration must change |
Import these categories from daita.errors, not from provider or adapter internals.
#Input and Lifecycle Errors
Some public facade methods deliberately raise standard Python exceptions for programmer mistakes or exact lifecycle conditions. Examples include TypeError, ValueError, KeyError, and focused agent-home exceptions.
Treat these as corrections to input or lifecycle usage, not transient service failures:
from pathlib import Path
from daita import Agent, LocalWorkspace
from daita.agent import AgentNotFoundError
try:
agent = await Agent.open(
"missing-agent",
workspace=LocalWorkspace(Path("/absolute/path/project")),
)
except AgentNotFoundError:
# Create the agent or correct the selected root/name.
...Consult the method contract before adding a broad retry around agent creation, source mutation, or local knowledge mutation.
#Retry at the Narrow Boundary
Provider routing performs bounded retries and fallbacks only for normalized eligible model failures. Do not retry an entire run blindly: a completed tool call or approved local write may already have occurred before the terminal failure.
A safe application policy is:
- log stable error metadata and the run ID when available;
- retry only errors marked transient or retryable;
- cap attempts and backoff time; and
- inspect the persisted transcript before replaying a whole request.
Observer callbacks are different: their exceptions are intentionally swallowed and never fail the agent run.