Uh oh!
There was an error while loading. Please reload this page.
test(e2e): Port cloudflare-vercelai-v7 to span streaming - #23863
Conversation
size-limit report 📦
|
9ab59af to
346c2fcCompare346c2fc to
7800f8eCompare7800f8e to
6cb6f44Compare6cb6f44 to
e2d1685CompareCo-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e2d1685 to
de3e557Compare| const invokeAgentSpan = genAiSpans.find(span => getSpanOp(span) === 'gen_ai.invoke_agent'); | ||
| const generateContentSpan = genAiSpans.find(span => getSpanOp(span) === 'gen_ai.generate_content'); |
There was a problem hiding this comment.
Bug: The test assumes invoke_agent and generate_content spans arrive in the same envelope. With streaming enabled, they might arrive separately, causing generateContentSpan to be undefined and the test to fail.
Severity: MEDIUM
Suggested Fix
To make the test robust against spans arriving in different envelopes, replace the waitForStreamedSpans function with collectStreamedSpans. The collectStreamedSpans function is designed to accumulate all spans for a trace across multiple envelopes, ensuring that both invoke_agent and generate_content spans are available for assertion regardless of how they are flushed.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/cloudflare-vercelai-v7/tests/index.test.ts#L15-L16
Potential issue: The test logic at this location has been updated to assert on streamed
spans. However, it uses the `waitForStreamedSpans` function, which only captures spans
from a single data envelope. With the removal of `traceLifecycle: 'static'`, the
Cloudflare SDK's `SpanStreaming` integration is enabled by default. This integration may
flush the `invoke_agent` and `generate_content` spans in separate envelopes. If this
occurs, `waitForStreamedSpans` will only capture the first envelope, likely containing
just the `invoke_agent` span. As a result, the `generateContentSpan` variable will be
`undefined`, causing the test assertion that checks its `parent_span_id` to fail.
Did we get this right? 👍 / 👎 to inform future reviews.
Uh oh!
There was an error while loading. Please reload this page.
Ports
cloudflare-vercelai-v7to span streaming. The spec already asserted on streamed spans, so this only removes the static pin and a comment that described gen_ai extraction as a special case.