Repository navigation
Expand file tree
/
Copy patherrors.py
More file actions
74 lines (49 loc) · 2.4 KB
/
Copy patherrors.py
File metadata and controls
74 lines (49 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Domain-level errors raised across application boundaries."""
from __future__ import annotations
class DomainError(Exception):
"""Base class for all domain-level errors."""
class WebhookSignatureError(DomainError):
"""Raised when an inbound webhook fails authenticity verification."""
class WebhookPayloadError(DomainError):
"""Raised when a Jira webhook payload cannot be normalized."""
class IdempotencyConflictError(DomainError):
"""Raised when an idempotency key is reused with different content."""
class RecursionDetectedError(DomainError):
"""Raised when a webhook is detected as triggered by the agent itself."""
class AssessmentValidationError(DomainError):
"""Raised when the LLM output fails structured-output validation after retries."""
class GuardrailBlockedError(AssessmentValidationError):
"""Raised when Bedrock Guardrails returned ``GUARDRAIL_INTERVENED``.
Subclassing :class:`AssessmentValidationError` keeps the existing
callers that catch the parent class working unchanged while letting
the :class:`agent.application.webhook_handler.WebhookHandler`
distinguish the policy-block path and surface
``InvokeResponse.error_type == "guardrail_blocked"`` in the
response, per the Wave 5 plan.
"""
def __init__(
self,
message: str,
*,
source: str,
guardrail_identifier: str,
guardrail_version: str,
) -> None:
super().__init__(message)
self.source = source
self.guardrail_identifier = guardrail_identifier
self.guardrail_version = guardrail_version
class ToolInvocationError(DomainError):
"""Raised when an MCP tool invocation fails terminally."""
class BudgetExceededError(DomainError):
"""Raised when a tenant's token or USD budget for the current window is exhausted.
Surfaces from :class:`agent.contracts.token_usage.TokenBudgetEnforcer.check`.
Audit-grade #6 lift: this is the deliberate fail-closed signal that prevents a
misconfigured webhook flood from racking up unbounded LLM spend.
"""
class LlmCircuitOpenError(DomainError):
"""Raised when the LLM circuit breaker is open and not yet ready to probe.
Surfaces from :class:`agent.contracts.token_usage.LlmCircuitBreaker.before_call`.
Audit-grade #5/#6 lift: the breaker terminates a retry storm before it can
burn additional tokens after a downstream LLM/MCP outage.
"""