Repository navigation
fix(decorator): preserve nested tool span parenting (SAO-19052) - #293
Conversation
etserend
left a comment
There was a problem hiding this comment.
🤖 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 unconditionallogger.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_CallStatefor every decorator-owned operation, not only for tools.
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. |
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
decorator.py.