Skip to content

Commit 329499e

Browse files
feat(tracing): infer error ownership from tracebacks
Add configurable frame ownership rules and safe provenance so uncategorized span failures can be attributed without inspecting exception text. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0f63017 commit 329499e

6 files changed

Lines changed: 685 additions & 25 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
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+
ERROR_CLASSIFIER_VERSION,
6+
DEFAULT_ERROR_CLASSIFIER_CONFIG,
7+
DEFAULT_TRACEBACK_OWNERSHIP_CONFIG,
8+
ErrorBoundary,
59
ErrorCategory,
610
PlatformError,
711
ApplicationError,
812
CategorizedError,
13+
ExceptionMapping,
14+
ErrorClassification,
15+
ErrorClassifierConfig,
16+
TracebackOwnershipConfig,
17+
classify_error,
918
)
1019
from agentex.lib.core.tracing.span_queue import (
1120
AsyncSpanQueue,
@@ -23,6 +32,15 @@
2332
"ApplicationError",
2433
"PlatformError",
2534
"ErrorCategory",
35+
"ErrorBoundary",
36+
"ExceptionMapping",
37+
"ErrorClassification",
38+
"ErrorClassifierConfig",
39+
"TracebackOwnershipConfig",
40+
"ERROR_CLASSIFIER_VERSION",
41+
"DEFAULT_ERROR_CLASSIFIER_CONFIG",
42+
"DEFAULT_TRACEBACK_OWNERSHIP_CONFIG",
43+
"classify_error",
2644
"AsyncSpanQueue",
2745
"get_default_span_queue",
2846
"shutdown_default_span_queue",

src/agentex/lib/core/tracing/processors/sgp_tracing_processor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ def _build_sgp_span(span: Span, env_vars: EnvironmentVariables) -> SGPSpan:
8888
if error is not None:
8989
sgp_span.set_error(error_type=error["type"], error_message=error["message"])
9090
sgp_span.metadata["error_category"] = error.get("category", "unknown")
91+
sgp_span.metadata["error_category_source"] = error.get("category_source", "legacy")
92+
sgp_span.metadata["error_classifier_version"] = error.get("classifier_version", "legacy")
93+
if "category_reason" in error:
94+
sgp_span.metadata["error_category_reason"] = error["category_reason"]
9195
return sgp_span
9296

9397

0 commit comments

Comments
 (0)