API Reference
ModelClient
Defined in: model.types.ts:148
The single LLM boundary the loop depends on.
Remarks
The loop never talks to a provider directly — it only depends on this interface, so any backend (mock, OpenAI-compatible, Anthropic, raw fetch) can be plugged in by implementing stream.
Example
const echo: ModelClient = {
async *stream(request) {
const message: AssistantMessage = { role: Role.Assistant, content: "hi" };
yield { type: StreamEventType.TextDelta, text: "hi" };
yield { type: StreamEventType.Done, message };
},
};Methods
stream()
stream(request): ModelStream;Defined in: model.types.ts:155
Begin a streaming completion. Implementations MUST stream by default.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ModelRequest | The system prompt, history, and tools for this turn. |
Returns
An async iterable of StreamEvents for the assistant turn.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
retainsReasoning? | readonly | boolean | Whether this model retains its FULL reasoning history across turns (GLM clear_thinking:false, Kimi/Qwen preserve_thinking:true) rather than only between tool calls. When true, the loop keeps reasoning on plain (non-tool-call) assistant turns too — so the resent history matches what the preserve kwarg promises — instead of stripping it. Omitted/false ⇒ interleaved-only: reasoning is kept on tool-call turns and dropped on plain turns (the default for every non-preserving model). See prepareRequestMessages | model.types.ts:168 |