Skip to content

Type Alias: ErrorCode

ts
type ErrorCode = 
  | "MISSING_DISCRIMINATOR"
  | "UNKNOWN_ACTION"
  | "VALIDATION_ERROR"
  | "MISSING_REQUIRED_FIELD"
  | "INTERNAL_ERROR"
  | "RATE_LIMITED"
  | "UNAUTHORIZED"
  | "FORBIDDEN"
  | "NOT_FOUND"
  | "CONFLICT"
  | "TIMEOUT"
  | "SERVER_BUSY"
  | "DEPRECATED"
  | "AUTH_REQUIRED"
  | string & {
};

Defined in: packages/core/src/core/response.ts:249

Canonical error codes for deterministic agent self-correction.

Provides compile-time autocomplete while allowing custom codes via the string fallback. Constants cover the most common failure modes in agentic pipelines.

Example

typescript
return toolError('VALIDATION_ERROR', { message: '...' });
return toolError('RateLimited', { message: '...' }); // custom code — also valid