mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
The LLM service exposed three call surfaces (stream/streamBlocks/generate) but the only production consumer — the agent loop — uses stream() exclusively, feeding raw chunks through its own BlockAssembler for replay fidelity. Drop the speculative convenience surfaces and the registry-change event that no listener consumed, leaving stream() as the single model-call contract for both production and tests. - Remove LlmService.streamBlocks() and generate(), the llm/generate waterfall, and GenerateResult. - Remove the llm/adapter-change event (declaration + emits) and the listener-throw rollback ordering that existed only to protect it; keep the HMR rollback disposer. - Remove BlockAssembler.flushReady()/flushRemaining()/result() and the flushed cursor — the streaming-flush slice existed only for streamBlocks(). - Adapter tests drive a stream()+BlockAssembler helper (tests/assemble.ts) instead of generate(), exercising the same path production uses. - Land the AGENTS.md "RFCs are proposals, not golden truth" principle and move both RFCs proposed -> implemented. Implements: - docs/rfc/implemented/simplification/2026-06-20-drop-unconsumed-llm-adapter-change-event.md - docs/rfc/implemented/simplification/2026-06-20-drop-unconsumed-llm-assembled-surfaces.md
27 lines
925 B
TypeScript
27 lines
925 B
TypeScript
/**
|
|
* Test helper: drive `ctx.llm.stream()` through a `BlockAssembler` and return
|
|
* the assembled message + usage + finish reason. This exercises the same
|
|
* streaming path production uses (the loop), rather than a service-level
|
|
* one-shot convenience method.
|
|
*/
|
|
|
|
import { BlockAssembler } from '@deepseek-ai/dsh-llm'
|
|
import type { Context } from 'cordis'
|
|
import type { FinishReason, GenerateOptions, Message, TokenUsage } from '@deepseek-ai/dsh-llm'
|
|
|
|
export interface AssembledResult {
|
|
message: Message
|
|
usage?: TokenUsage
|
|
finish: FinishReason
|
|
}
|
|
|
|
export async function assemble(ctx: Context, options: GenerateOptions): Promise<AssembledResult> {
|
|
const assembler = new BlockAssembler()
|
|
for await (const chunk of ctx.llm.stream(options)) assembler.push(chunk)
|
|
return {
|
|
message: assembler.message(),
|
|
...assembler.usage !== undefined ? { usage: assembler.usage } : {},
|
|
finish: assembler.finish,
|
|
}
|
|
}
|