Skip to content

fix(decorator): preserve nested tool span parenting (SAO-19052) - #293

Merged
pradystar merged 2 commits into
mainfrom
fix/sao-19052-nested-tool-topology
Oct 26, 2026
Merged

pradystar merged 2 commits into
mainfrom
fix/sao-19052-nested-tool-topology

Conversation

@pradystar

Copy link
Copy Markdown
Collaborator

Summary

Fixes SAO-19052.

Decorated tool spans were created after the function returned, causing nested tools to attach to the enclosing agent or workflow.

Start and activate decorated tool spans before execution, then conclude them afterward. This preserves nested parenting, exposes the tool’s tracing context during execution, and restores the caller before subsequent sibling calls.

Production changes are limited to decorator.py. Handler, public logger, native OTel, and LLM/retriever leaf behavior remain unchanged.

Validation

  • Confirmed the defect with failing sync and async regressions before implementation.
  • Compatibility suites: 458 passed, 1 skipped.
  • Covered nested and sibling parenting, caller context, cancellation, concurrent calls, and generator cleanup.
  • Ruff lint and formatting checks passed.
  • Configured type check passed; it excludes decorator.py.

@pradystar
pradystar marked this pull request as ready for review October 23, 2026 21:05

@etserend etserend left a comment

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.

🤖 This review was generated by the Astra agent (claude-opus-5-5). It may contain mistakes.

Verdict: request_changes — Generator tools now stay active as the current parent between yields, so consumer code becomes misparented and conclude() can close the wrong span.

Addressed before this review

  • Generator tools stayed active as current parent between yields. This misparented consumer calls and let conclude() close the wrong span with swapped output (decorator.py:815). Not addressed: HEAD is still 29a480e, the commit this concern was raised against. It is raised again in this review.

Follow-ups

Suggested follow-up work that could be tracked as Jira tickets:

  • src/splunk_ao/decorator.py:1052-1062: Workflow and agent decorators also complete through an unconditional logger.conclude() on whatever span is current. A leaked or interleaved operation can make them close the wrong span. Consider concluding the specific span recorded on _CallState for every decorator-owned operation, not only for tools.

Comment thread src/splunk_ao/decorator.py Resolved
@pradystar

Copy link
Copy Markdown
Collaborator Author

Addressed before this review
Generator tools stayed active as current parent between yields. This misparented consumer calls and let conclude() close the wrong span with swapped output (decorator.py:815). Not addressed: HEAD is still 29a480e, the commit this concern was raised against. It is raised again in this review.

Not sure what you mean by raised again, its the first review against 29a480e

Fixed both focused review comments and the workflow/agent generator follow-up, with regression coverage for context restoration, interleaved outputs, and cleanup.

@pradystar
pradystar merged commit d74f8fc into main Oct 26, 2026
13 checks passed
@pradystar
pradystar deleted the fix/sao-19052-nested-tool-topology branch October 26, 2026 15:31
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants