Classify workflow errors so the worker can decide retry vs. user-error. Port of clawrecipes/src/lib/workflows/workflow-error-classify.ts. The TS version interrogates ``ToolsInvokeError`` for an HTTP status; here we accept any exception with an ``http_status`` (or ``httpStatus``)
# Source: https://github.com/JIGGAI/hermes-recipes | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Classify workflow errors so the worker can decide retry vs. user-error.
Port of clawrecipes/src/lib/workflows/workflow-error-classify.ts. The TS
version interrogates ``ToolsInvokeError`` for an HTTP status; here we accept
any exception with an ``http_status`` (or ``httpStatus``) attribute so the
classifier remains decoupled from the tool-invocation client.
"""
import re
from typing import Any, Literal
ErrorCategory = Literal["funding", "rate-limit", "auth", "timeout", "unknown"]
_FUNDING_PATTERNS = (
re.compile(r"insufficient.*(credits?|funds?|balance)", re.IGNORECASE),
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key