Skip to content

Add regression test for invisible provider stream-error retries - #30

Merged
bezbac merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/stream-error-retry-generation-drop
Aug 19, 2026
Merged

bezbac merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/stream-error-retry-generation-drop

Conversation

@DavidTraina

Copy link
Copy Markdown
Contributor

Fixes #21

Opening this as a draft for maintainer review, as invited in the issue.

What

Adds a regression test to test/integration/plugin.test.ts covering opencode's invisible provider stream-error retries. When a provider stream errors mid-call, opencode retries inside its session processor and re-streams the same assistant message. The plugin sees no session.error and no lifecycle event for the aborted attempt, only a session.status retry.

Why

In 0.1.0 this sequence left tool observations parented to generation spans that were never exported, so the tools were orphaned in Langfuse. The test pins the current (fixed) behavior so it can't regress:

  • The retried message settles into exactly one exported generation, spanning from the original start to the successful completion, with usage from the successful attempt.
  • Every subsequent tool observation (whether reported via message parts or only via execution hooks, including after a duplicate completion delivery) parents to a span that is actually exported.

How tested

  • pnpm run test:integration passes (14 tests).
  • Verified the test fails against reintroduced bugs: removing the step.span.end() call in traceGeneration, and separately disabling the start-after-completion guard in startActiveGenerationStep, both make it fail.

opencode retries provider stream errors inside its session processor,
re-streaming the same assistant message; the plugin sees no session.error
and no lifecycle event for the aborted attempt (only a session.status
retry). Pin that the retried message settles into exactly one exported
generation spanning the retry window, with usage from the successful
attempt, and that every subsequent tool observation's parent resolves to
an exported span - the invariant that was violated in 0.1.0, where tools
after a retry referenced never-exported generation spans.
@DavidTraina
DavidTraina marked this pull request as ready for review August 18, 2026 19:05
@bezbac
bezbac merged commit 9e8b8e1 into langfuse:main Aug 19, 2026
3 checks passed
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.

Add regression test for invisible provider stream-error retries

2 participants