Open Agent Loops
API Reference

ModelClient

@open-agent-loops/core


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

ParameterTypeDescription
requestModelRequestThe system prompt, history, and tools for this turn.

Returns

ModelStream

An async iterable of StreamEvents for the assistant turn.

Properties

PropertyModifierTypeDescriptionDefined in
retainsReasoning?readonlybooleanWhether 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 prepareRequestMessagesmodel.types.ts:168

On this page