Skip to content

Commit 6f27da0

Browse files
refactor: use canonical SGP error categories
Require the released tracing SDK types so Agentex no longer maintains a duplicate ownership taxonomy that can drift. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f24aef5 commit 6f27da0

5 files changed

Lines changed: 26 additions & 32 deletions

File tree

adk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies = [
5353
"pydantic-ai-slim>=1.0,<2",
5454
"langgraph-checkpoint>=2.0.0",
5555
"scale-gp>=0.1.0a59",
56-
"scale-gp-beta>=0.2.0",
56+
"scale-gp-beta>=0.5.0",
5757
"mcp>=1.4.1",
5858
# Observability
5959
"ddtrace>=3.13.0",

src/agentex/lib/core/tracing/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from agentex.lib.core.tracing.trace import Trace, AsyncTrace
33
from agentex.lib.core.tracing.tracer import Tracer, AsyncTracer
44
from agentex.lib.core.tracing.span_error import (
5+
ErrorCategory,
56
PlatformError,
67
ApplicationError,
78
CategorizedError,
@@ -21,6 +22,7 @@
2122
"CategorizedError",
2223
"ApplicationError",
2324
"PlatformError",
25+
"ErrorCategory",
2426
"AsyncSpanQueue",
2527
"get_default_span_queue",
2628
"shutdown_default_span_queue",

src/agentex/lib/core/tracing/span_error.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
from __future__ import annotations
22

3-
from typing import Any, Literal, cast
3+
from typing import Any, cast
4+
5+
from scale_gp_beta.lib.tracing import (
6+
PlatformError as PlatformError,
7+
ApplicationError as ApplicationError,
8+
CategorizedError,
9+
)
10+
from scale_gp_beta.lib.tracing.types import ErrorCategory
411

512
from agentex.types.span import Span
613

@@ -13,36 +20,10 @@
1320
# SGP and agentex-native span stores.
1421
SPAN_ERROR_KEY = "__error__"
1522

16-
ErrorCategory = Literal["application", "platform", "unknown"]
1723
ERROR_CATEGORY_UNKNOWN: ErrorCategory = "unknown"
1824
_ERROR_CATEGORIES = frozenset({"application", "platform", "unknown"})
1925

2026

21-
class CategorizedError(Exception):
22-
"""Base class for failures with known operational ownership.
23-
24-
Use ``ApplicationError`` for failures owned by agent or caller code, such
25-
as business logic, user input, tools, or application configuration. Use
26-
``PlatformError`` only at a known Agentex/SGP-owned boundary, such as
27-
managed runtime, tracing, persistence, or platform networking. Leave
28-
unclassified failures as ordinary exceptions so they remain ``unknown``.
29-
"""
30-
31-
error_category: ErrorCategory = ERROR_CATEGORY_UNKNOWN
32-
33-
34-
class ApplicationError(CategorizedError):
35-
"""Failure owned by the agent application or its caller."""
36-
37-
error_category: ErrorCategory = "application"
38-
39-
40-
class PlatformError(CategorizedError):
41-
"""Failure owned by Agentex/SGP or a platform-managed dependency."""
42-
43-
error_category: ErrorCategory = "platform"
44-
45-
4627
def _normalize_error_category(value: object) -> ErrorCategory | None:
4728
if isinstance(value, str):
4829
normalized = value.strip().lower()

tests/lib/core/tracing/test_span_error.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
from unittest.mock import MagicMock, patch
77

88
import pytest
9+
from scale_gp_beta.lib.tracing import (
10+
PlatformError as SGPPlatformError,
11+
ApplicationError as SGPApplicationError,
12+
CategorizedError as SGPCategorizedError,
13+
)
914

1015
from agentex.types.span import Span
1116
from agentex.lib.core.tracing.trace import Trace, AsyncTrace
1217
from agentex.lib.core.tracing.span_error import (
1318
SPAN_ERROR_KEY,
1419
PlatformError,
1520
ApplicationError,
21+
CategorizedError,
1622
get_span_error,
1723
set_span_error,
1824
)
@@ -36,6 +42,11 @@ def _make_span(data=None) -> Span:
3642

3743

3844
class TestSpanErrorHelpers:
45+
def test_uses_canonical_sgp_error_types(self):
46+
assert CategorizedError is SGPCategorizedError
47+
assert ApplicationError is SGPApplicationError
48+
assert PlatformError is SGPPlatformError
49+
3950
def test_set_then_get_on_none_data(self):
4051
span = _make_span(data=None)
4152
set_span_error(span, ValueError("boom"))

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)