Skip to content

fix(sdk): end synchronous generator spans on early exit - #1471

Open
zwk110 wants to merge 1 commit into
AgentOps-AI:mainfrom
zwk110:codex/end-sync-generator-spans
Open

zwk110 wants to merge 1 commit into
AgentOps-AI:mainfrom
zwk110:codex/end-sync-generator-spans

Conversation

@zwk110

@zwk110 zwk110 commented Oct 21, 2026

Copy link
Copy Markdown

Description

When a started synchronous generator raises or is explicitly closed, _process_sync_generator() skips span.end(). The task/trace span then never reaches the exporter. End it in finally, matching the asynchronous helper's lifecycle handling while preserving yielded values, exception propagation, and generator cleanup.

Testing

  • Four regression cases exercise task and trace decorators with a post-yield exception or close(), using the existing in-memory exporter fixture. All four fail against the original source.
  • pytest tests/unit/sdk/test_decorators.py tests/unit/sdk/test_factory.py -q: 83 passed (Windows, Python 3.12.11).
  • Changed-file pre-commit hooks and git diff --check passed. Full SDK and integration suites were not run.

This branch has not been deployed

No deployments
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.

1 participant