Problem
Within a single trace, tool observations can be parented to the previous assistant generation when generation lifecycle events arrive out of order.
This happens when a late lifecycle event from an earlier generation overwrites the current generation state.
Expected Behavior
Each tool observation should be parented to the assistant generation that requested it.
Current Behavior
The generation and tool observations share the same trace ID, but the tools are assigned the wrong parentObservationId.
For three consecutive generations and tool batches:
The tools execute in the correct order, but their parent relationships appear one generation behind in Langfuse.
Fix
I prepared and tested a fix:
The patched result is [1, 2, 3]. Formatting, build, and regression tests pass.
PR creation is currently limited to collaborators. Could a maintainer create a cross-fork PR from this branch or cherry-pick the commit?
Environment
- OpenCode: 1.16.2
- Plugin: 0.1.0
- Langfuse: Cloud
Problem
Within a single trace, tool observations can be parented to the previous assistant generation when generation lifecycle events arrive out of order.
This happens when a late lifecycle event from an earlier generation overwrites the current generation state.
Expected Behavior
Each tool observation should be parented to the assistant generation that requested it.
Current Behavior
The generation and tool observations share the same trace ID, but the tools are assigned the wrong
parentObservationId.For three consecutive generations and tool batches:
The tools execute in the correct order, but their parent relationships appear one generation behind in Langfuse.
Fix
I prepared and tested a fix:
The patched result is
[1, 2, 3]. Formatting, build, and regression tests pass.PR creation is currently limited to collaborators. Could a maintainer create a cross-fork PR from this branch or cherry-pick the commit?
Environment