Skip to content

Tool observations can be parented to the previous generation within a trace #9

Description

@csh-scl

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.

[1, 2, 3]

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:

[1, 1, 2]

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

Metadata

Metadata

Assignees

Labels

PublicbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions