Skip to content

Add reusable test fixtures for E2E testing with real AI SDK pipeline #20206

@rmk40

Description

@rmk40

Problem

Several tests need to exercise the real AI SDK streamText pipeline (not TestLLM mocks) against a fake HTTP server. Currently, llm.test.ts has its own inline fake server and SSE helpers, and any new test that needs the same infrastructure has to duplicate ~200 lines of boilerplate.

There is also no shared layer stack for tests that need the full SessionPrompt pipeline (tool registration via ToolRegistry, resolveTools, processor event handling) with a real LLM layer.

Proposal

Add two reusable test fixtures:

  1. test/fixture/anthropic.ts — Fake Anthropic HTTP server (Bun.serve({port:0})) with lifecycle management (start/stop/reset) and SSE response helpers (toolResponse, textResponse, sse, waitRequest, deferred).

  2. test/fixture/prompt-layers.ts — Full SessionPrompt Effect layer stack with real LLM.defaultLayer and no-op stubs for MCP/LSP/FileTime. Exports a single env layer that testEffect(env) can consume.

These fixtures unblock E2E tests for tool execution, metadata propagation, permission handling, and any other scenario that needs the complete prompt pipeline without mocking the LLM.

Context

Needed for the regression test in #20184 and reusable for future E2E tests.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions