Error Reference
All error types thrown by the HUMΛN agent SDK. Every error extendsSDKError and carries a machine-readablecode string for reliable programmatic handling.
Import
import { SDKError, AccessDeniedError, NotFoundError, TimeoutError, NotImplementedError, BudgetExceededError, DelegationExpiredError, InvalidInputError,} from '@human/agent-sdk';Handling Errors
Use instanceof checks to distinguish error types. Not all errors are retryable — AccessDeniedError andBudgetExceededError will not resolve on retry.
import { AccessDeniedError, BudgetExceededError, TimeoutError } from '@human/agent-sdk';
export default handler({ name: 'resilient-agent', execute: async (ctx, input) => { try { const response = await ctx.llm.complete({ prompt: input.query }); return { result: response.content };
} catch (err) { if (err instanceof BudgetExceededError) { // Delegation budget is exhausted — don't retry ctx.log.error('Budget exceeded', { budget: err.budget, spent: err.spent }); return { error: 'budget_exceeded', message: 'Processing limit reached.' }; }
if (err instanceof AccessDeniedError) { // Missing delegation scope — not retryable ctx.log.warn('Access denied', { scope: err.requiredScope }); return { error: 'unauthorized', message: 'Insufficient permissions.' }; }
if (err instanceof TimeoutError) { // LLM or agent call took too long — may be retryable ctx.log.warn('Operation timed out', { operation: err.operation }); return { error: 'timeout', message: 'Operation took too long.' }; }
// Unknown error — re-throw to let the runtime handle it throw err; } },});Using Error Codes
// All SDK errors have a machine-readable codetry { await ctx.secrets.get('DB_PASSWORD');} catch (err) { if (err instanceof SDKError) { console.log(err.code); // 'ACCESS_DENIED' console.log(err.message); // Human-readable message console.log(err.cause); // Original error (if wrapped) }}All Error Types
SDKErrorSDK_ERRORBase class for all SDK errors. All other error types extend this.
Additional fields
message: stringcode: stringcause?: unknownThrown by
Any ctx.* call on unexpected infrastructure failure.
AccessDeniedErrorACCESS_DENIEDThe agent's delegation does not include the required scope for this operation.
Additional fields
requiredScope?: stringagentId: stringThrown by
ctx.secrets.get(), ctx.llm.complete(), ctx.db.query(), ctx.call.agent(), ctx.prompts.load()
BudgetExceededErrorBUDGET_EXCEEDEDThe operation would exceed the cost budget defined in the delegation.
Additional fields
budget: numberspent: numbercurrency: stringThrown by
ctx.llm.complete(), ctx.llm.embed(), ctx.call.agent()
TimeoutErrorTIMEOUTAn operation exceeded its configured timeout.
Additional fields
operation: stringtimeoutMs: numberThrown by
ctx.llm.complete(), ctx.call.agent(), ctx.call.human(), ctx.call.route()
DelegationExpiredErrorDELEGATION_EXPIREDThe delegation granted to this agent has expired.
Additional fields
expiredAt: numberdelegationId: stringThrown by
Any ctx.* call after the delegation TTL.
NotFoundErrorNOT_FOUNDThe requested resource (agent, passport, secret) does not exist.
Additional fields
resourceType: stringresourceId: stringThrown by
ctx.call.agent(), ctx.secrets.get(), ctx.provenance.get()
InvalidInputErrorINVALID_INPUTThe input to the agent or method failed validation.
Additional fields
field?: stringexpected?: stringThrown by
handler() execute function when input schema validation fails.
NotImplementedErrorNOT_IMPLEMENTEDThe requested operation is not available in the current deployment or runtime.
Additional fields
operation: stringThrown by
ctx.* calls on operations not supported by the current runtime.