Skip to main content

Error Response Format

{
  "error": {
    "code": "QWED-001",
    "message": "Verification failed",
    "details": {
      "engine": "math",
      "reason": "Invalid expression syntax"
    }
  }
}

General Errors

CodeHTTPMessage
QWED-001400Invalid request format
QWED-002401Invalid or missing API key
QWED-003403Access denied
QWED-004404Resource not found
QWED-005429Rate limit exceeded
QWED-006500Internal server error
QWED-007503Service temporarily unavailable

Verification Errors

CodeMessage
QWED-100Unknown verification type
QWED-101Query is empty
QWED-102Query too long
QWED-103Invalid expression syntax
QWED-104Engine timeout
QWED-105Unsupported language

Execution Errors

CodeHTTPMessage
QWED-300503Secure execution runtime unavailable — the Docker sandbox is not reachable
QWED-301403Verification blocked by security policy
These errors apply to the /verify/stats and /verify/consensus endpoints. Statistical and consensus Python verification requires the secure Docker sandbox. When Docker is unavailable, the API returns 503 instead of falling back to in-process execution.

Security Errors

CodeMessage
QWED-200Prompt injection detected
QWED-201SQL injection detected
QWED-202Dangerous code pattern
QWED-203Blocked content

Agent errors

CodeMessage
QWED-AGENT-001Agent not registered
QWED-AGENT-002Invalid agent token
QWED-AGENT-003Agent suspended
QWED-AGENT-004Action not permitted
QWED-AGENT-BUDGET-001Daily cost limit exceeded
QWED-AGENT-BUDGET-002Hourly rate limit exceeded

Agent context errors

New in v5.0.0
CodeMessage
QWED-AGENT-CTX-001Action context with conversation_id and step_number is required
QWED-AGENT-CTX-002step_number must be >= 1

Agent loop detection errors

New in v5.0.0
CodeMessage
QWED-AGENT-LOOP-001Conversation step limit exceeded (max 50 steps)
QWED-AGENT-LOOP-002Replay or out-of-order action step detected
QWED-AGENT-LOOP-003Repetitive action loop detected (same action more than 2 consecutive times)
QWED-AGENT-LOOP-004No-progress doom loop detected — agent is repeating the same action on an unchanged world state (≥ 3 times in the sliding window)

Agent state errors

New in v5.1.0
These errors relate to the progress-aware doom loop guard (LOOP-004). They are returned when the pre_action_state_hash or state_source context fields are invalid.
CodeMessage
QWED-AGENT-STATE-001pre_action_state_hash and state_source must be provided together (or are required when DOOM_LOOP_GUARD_REQUIRED is enabled)
QWED-AGENT-STATE-002pre_action_state_hash must be a 64-character lowercase hex SHA-256 digest
QWED-AGENT-STATE-003state_source must be one of: file_tree, db_snapshot, conversation_digest, git_tree, custom
QWED-AGENT-STATE-004Action parameters contain non-deterministic JSON-incompatible values

Attestation Errors

CodeMessage
QWED-ATT-001Invalid attestation format
QWED-ATT-002Attestation expired
QWED-ATT-003Attestation revoked
QWED-ATT-004Untrusted issuer
QWED-ATT-005Signature verification failed

Exception hierarchy

The QWED SDK and server use a structured exception hierarchy that provides actionable error messages with suggestions and documentation links. All exceptions extend the base QWEDError class.

Base exception

All QWED exceptions include these fields:
FieldTypeDescription
messagestringHuman-readable error description
suggestionstring | nullActionable fix recommendation
docs_urlstringLink to relevant documentation
detailsobjectAdditional context (engine, expression, etc.)

DSL and parsing exceptions

ExceptionTriggerDetails
QWEDSyntaxErrorInvalid DSL expression syntaxIncludes expression, line, and column fields for precise error location
QWEDSymbolNotFoundErrorUnknown variable or function in expressionIncludes “did you mean?” suggestions from available symbols

Verification exceptions

ExceptionEngineDetails
QWEDVerificationErrorAnyBase class for all verification failures. Includes expected, actual, and engine fields
QWEDMathErrorMathIncludes expression, expected, calculated, and tolerance values
QWEDLogicErrorLogicIncludes formula and counterexample model when available
QWEDCodeErrorCodeIncludes code, output, expected_output, and execution_error
QWEDSQLErrorSQLIncludes query, schema, and specific issue description

Configuration and API exceptions

ExceptionTriggerDetails
QWEDConfigErrorInvalid configurationIncludes config_key, expected_type, and actual_value
QWEDAPIErrorAPI communication failureIncludes status_code and endpoint. Provides targeted suggestions per status code (401 = check API key, 429 = rate limit, etc.)
QWEDDependencyErrorMissing packageIncludes install command (e.g., pip install sympy)

Handling errors

Python

from qwed_sdk import QWEDClient, QWEDError

try:
    result = client.verify("test")
except QWEDError as e:
    print(f"Error: {e.message}")
    print(f"Suggestion: {e.suggestion}")
    print(f"Details: {e.details}")
    print(f"Docs: {e.docs_url}")

Catching specific exceptions

from qwed_sdk import QWEDClient
from qwed_new.core.exceptions import (
    QWEDMathError,
    QWEDSyntaxError,
    QWEDConfigError,
)

try:
    result = client.verify_math("invalid expression $$")
except QWEDSyntaxError as e:
    print(f"Syntax error at column {e.column}: {e.message}")
except QWEDMathError as e:
    print(f"Math error: expected {e.expected}, got {e.actual}")
except QWEDConfigError as e:
    print(f"Config issue with '{e.details.get('config_key')}': {e.message}")

TypeScript

import { QWEDError } from '@qwed-ai/sdk';

try {
  const result = await client.verify('test');
} catch (error) {
  if (error instanceof QWEDError) {
    console.log(`Error ${error.code}: ${error.message}`);
  }
}