Skip to content

Propagate error categories to SGP spans - #486

Open
jshaikScale wants to merge 1 commit into
mainfrom
javed/error-category-producers
Open

Propagate error categories to SGP spans#486
jshaikScale wants to merge 1 commit into
mainfrom
javed/error-category-producers

Conversation

@jshaikScale

@jshaikScale jshaikScale commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • capture exceptions raised inside ADK span context managers before ending the span
  • normalize producer-provided error ownership to application, platform, or unknown
  • emit flat error_category metadata alongside SGP status=ERROR, while remaining compatible with the current scale-gp-beta SDK
  • add coverage for explicit classification, fallback behavior, ADK capture, and SGP mapping

Test plan

  • .venv/bin/pytest -n 0 tests/lib/core/tracing/test_span_error.py tests/lib/adk/test_tracing_module.py
  • .venv/bin/pytest -n 0 tests/lib/core/tracing/processors/test_sgp_tracing_processor.py
  • .venv/bin/ruff check on changed files
  • .venv/bin/pyright --pythonpath .venv/bin/python on changed implementation files

Made with Cursor

Greptile Summary

This PR propagates normalized error ownership into SGP tracing spans.

  • Captures exceptions raised inside ADK span context managers before ending the span.
  • Normalizes producer-supplied categories to application, platform, or unknown.
  • Adds flat error_category metadata to errored SGP spans with legacy fallback behavior.
  • Extends unit coverage for classification, ADK exception capture, and SGP mapping.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The changed paths preserve original exception propagation, normalize invalid or missing categories predictably, remain compatible with legacy error records, and attach the category to errored SGP spans.

Important Files Changed

Filename Overview
src/agentex/lib/core/tracing/span_error.py Adds validated error-category extraction while retaining the existing reserved span-error representation.
src/agentex/lib/core/tracing/processors/sgp_tracing_processor.py Maps recorded categories into flat SGP metadata and safely defaults legacy records to unknown.
src/agentex/lib/adk/_modules/tracing.py Records exceptions raised within ADK span bodies before ending the span and reraising the original exception.
tests/lib/core/tracing/test_span_error.py Covers category normalization, precedence, fallback behavior, context-manager capture, and SGP metadata mapping.
tests/lib/adk/test_tracing_module.py Verifies that ADK span contexts record body exceptions, close the span, and reraise the error.

Reviews (1): Last reviewed commit: "feat: propagate error categories to SGP ..." | Re-trigger Greptile

Capture ADK failures and preserve producer ownership metadata so SGP can distinguish application, platform, and unknown errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

This PR is targeting main, but PRs should target the next branch by default.

The main branch is reserved for release-please and Stainless automation. To resolve, pick one of:

  • Re-target the PR to next (recommended). On the PR page, click Edit next to the title and change the base branch to next.
  • Add the target-main label if this is an intentional exception (e.g. an urgent hotfix). The check will re-run and pass.

See CONTRIBUTING.md for the full branch model.

# SGP and agentex-native span stores.
SPAN_ERROR_KEY = "__error__"

ErrorCategory = Literal["application", "platform", "unknown"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have this mapping anywhere? How are we deciding what counts as a platform failure versus an application failure?

# SGP and agentex-native span stores.
SPAN_ERROR_KEY = "__error__"

ErrorCategory = Literal["application", "platform", "unknown"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, rn any exception can opt into error_category via a bare getattr-checked attribute.. there's no shared base class, protocol, or documented convention pointing producers to this. Could we add a small CategorizedError/PlatformError/ApplicationError base so this is discoverable and type-checked, rather than an implicit attribute contract someone has to know to add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants