Skip to content

test(session): add LLM stream mock harness for processor integration tests #219

@randomm

Description

@randomm

Context

PR #214 fixed the pending tool state bug in processor.ts. The code review requested tests that call processor.process() directly, but this is not currently feasible because processor.process() calls LLM.stream() internally which requires active provider installations, API credentials, Config DB, and Instance context.

The existing "integration" tests in test/core/stream.test.ts also do not call process() — they only verify typeof processor.process === "function".

Goal

Build a test harness that allows processor.process() to be called in unit tests by providing a mockable LLM.stream that emits synthetic stream events.

Acceptance Criteria

  • A mock factory createMockStream(events: StreamEvent[]) that returns an object compatible with LLM.StreamInput
  • At minimum, the mock must support emitting: tool-input-start, tool-call, tool-result, tool-error, text-delta, finish
  • At least one test in test/session/processor.test.ts that calls processor.process(mockStream) end-to-end
  • The harness does not require network access, API keys, or a running database

Why

This would enable proper integration tests for processor stream handler logic, including the pending tool fix in #214.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions