test(e2e): Add a node-flue end-to-end application - #24377
Conversation
size-limit report 📦
|
8f35f04 to
c9a3c7b
Compare
6232570 to
be1be03
Compare
| const hasOps = (ops: string[]) => (spansOfTrace: { attributes?: Record<string, { value?: unknown }> }[]) => | ||
| ops.every(op => spansOfTrace.some(span => getSpanOp(span) === op)); | ||
|
|
||
| test('captures the invoke_agent / chat / execute_tool hierarchy for a Flue turn', async ({ baseURL }) => { |
There was a problem hiding this comment.
somewhere here we should also test the http.server spans. as this uses hono, it will today likely be unparametrized, which we should codify in the test. once #24371 lands this should automatically be captured as hono spans too then!
There was a problem hiding this comment.
had a go at this but couldn't get the assertion working, adding http.server to the collectStreamedSpans predicate hangs, same with waitForTransaction on the op. the segment ships in its own envelope at the 202, well before the children, so i suspect the proxy/helper path rather than the sdk, clanker REALLY went through it 😅 i couldn't pin it down yet
the spans themselves are fine though. dumped the transport for one turn: single trace, agent tree parented under http.server, and unparametrized exactly as you guessed POST
I'll leave the assertion out rather than landing something flaky, happy to revisit once #24371 lands since the shape changes there anyway
be1be03 to
707b1f5
Compare
9abab72 to
8d0cf18
Compare
| { name: 'resolve-weather', attributes: { 'weather.source': 'static-table', 'weather.city': city } }, | ||
| () => { | ||
| return `It is 21 degrees and sunny in ${city}.`; | ||
| }, |
There was a problem hiding this comment.
Tool handler reads wrong arguments
Medium Severity
get_weather's run callback destructures city from the tool context, but Flue puts validated input on data. city is therefore always undefined, so the model gets a useless tool result and the weather.city span attribute is never set.
Reviewed by Cursor Bugbot for commit 8d0cf18. Configure here.
The node-integration-test suite drives Flue from a hand-written scenario that calls `__flueBindAgentModule` itself, standing in for what `@flue/vite` does at build time. It cannot show whether a scaffolded app works. This app is what `flue init` produces — plain vite, `'use agent'`, `createAgentRouter` — built and served the way a user runs it, against a real provider. Covers: AI spans, errors captured as issues, a manual span nesting inside a tool, an orchestrion-instrumented `dataloader` span landing in the agent's trace, and both dev and prod. Also asserts the provider's HTTP call nests inside `chat`, which nothing else covers. The loader is called from inside a tool rather than a route, so its span shares the agent's trace instead of sitting in one of its own. No build externals are needed, unlike node-eve: a Flue node build leaves dependencies as bare specifiers, so `dataloader` stays a real module for the transform to hook. The `@flue/*` versions are pinned because the internal registry proxy 403s on releases it has not scanned, and a caret range drifts onto them; the `(latest)` variant is where new versions get exercised. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two lines over the width limit; I formatted the server-utils sources but not the test application. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`runAgentTurn` returned on the `202` and dropped the `streamUrl`, so a turn kept running while the next test started waiting for spans — a leftover trace could satisfy the wrong assertion. It now reads the conversation back until it reports a settlement. Scoping the waits by `gen_ai.conversation.id` would not have worked: Flue generates that id (`conv_01M2G81…`), so it is not the path segment the test chose and the test cannot know it up front. Also names `count_items` in the agent instructions — an earlier edit missed, so the dataloader test was relying on the tool description alone — and drops the `loaders.ts` comment describing the route-based setup that no longer exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Drop the explicit `dataloaderIntegration()`; it is in `getTracingIntegrations()` now, so Node registers it by default when spans are enabled. - Always run under orchestrion rather than keeping it as a variant, since that is how the SDK is meant to be set up. Removes the `*:orchestrion` scripts, the `USE_ORCHESTRION` plumbing and the `test.fail()` branch in the dataloader test, which now simply asserts the span lands under `execute_tool`. - Drop the node-eve reference from `vite.config.ts`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three things made it flaky on a Playwright retry, which is why the dev run went red then green: - `DataLoader` was a module-level singleton, so it cached keys 1-3 and a second `count_items` call skipped the batch function and emitted no span. Constructed per execution now, matching node-eve. - Conversation ids were fixed strings, so `runAgentTurn` saw a settlement from an earlier run and returned before the new turn finished. Each turn gets its own. - The waits matched any agent turn, so a leftover trace could satisfy the wrong test. Each now anchors on its own tool via `gen_ai.tool.name`. The dataloader test asserts a shared trace rather than the exact parent: the model may call the tool more than once, and the span that ran the loader is not reliably the one found by name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
8d0cf18 to
1478c0a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1478c0a. Configure here.
| const providerCall = spans.find(span => getSpanOp(span) === 'http.client'); | ||
|
|
||
| expect(providerCall?.trace_id).toBe(chat?.trace_id); | ||
| expect(providerCall?.parent_span_id).toBe(chat?.span_id); |
There was a problem hiding this comment.
HTTP nesting test matches leftover traces
Medium Severity
This test’s collectStreamedSpans predicate only looks for gen_ai.chat and http.client, which every Flue turn emits. collectStreamedSpans resolves on the earliest matching trace, so a late envelope from the preceding weather tests can satisfy it. Flagged because the testing conventions require wait conditions unique enough that leftover telemetry cannot win.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 1478c0a. Configure here.


Stacked on #24266 — review that first, this is the e2e app only.
The node-integration-test calls
__flueBindAgentModuleby hand, standing in for what@flue/vitedoes from the'use agent'directive, so it can't show whether a scaffolded app actually works. This isflue initoutput, built and served the way a user runs it, against a real provider.Covered, in both dev and prod and in both the base and orchestrion variants:
invoke_agent/chat/execute_toolwith usage and costexecute_tooldataloaderspan landing in the agent's tracehttp.clientcall nesting insidechatThe loader runs inside a tool rather than a route so its span shares the agent's trace. No build externals are needed unlike
node-eve— a Flue node build leaves dependencies as bare specifiers, sodataloaderstays a real module for the transform to hook.@flue/*is pinned because the internal registry proxy 403s on releases it hasn't scanned.Found: a thrown tool error produced an errored span and no issue at all, since Flue catches the throw and hands it back to the model as a tool result. Fixed in #24265.