Open Agent Loops
API Reference

MessageQueue

@open-agent-loops/core


Defined in: primitives/message-queue.ts:61

A FIFO queue of Messages for the loop's steering / follow-up seams — the unbounded specialization of BoundedBuffer (capacity: Infinity), so the overflow policy never engages and it behaves as a plain FIFO.

Remarks

Pure and host-agnostic: no timers, no I/O. drain returns messages in the order they were pushed and removes what it returns, so it plugs straight into Hooks.drainSteering / Hooks.drainFollowUp — which expect exactly "the messages to inject now, having consumed them".

Reach for BoundedBuffer directly when you need a cap and an overflow policy — e.g. a live-ingress dispatcher queue or outbound reply coalescing.

Extends

Accessors

dropped

Get Signature

get dropped(): number;

Defined in: primitives/bounded-buffer.ts:170

Total items dropped (evicted + refused) over this buffer's lifetime.

Returns

number

Inherited from

BoundedBuffer.dropped


highWater

Get Signature

get highWater(): number;

Defined in: primitives/bounded-buffer.ts:175

The largest size this buffer has reached — the backpressure read.

Returns

number

Inherited from

BoundedBuffer.highWater


size

Get Signature

get size(): number;

Defined in: primitives/bounded-buffer.ts:165

Number of items currently buffered.

Returns

number

Inherited from

BoundedBuffer.size

Constructors

Constructor

new MessageQueue(options?): MessageQueue;

Defined in: primitives/message-queue.ts:65

Parameters

ParameterTypeDescription
optionsMessageQueueOptionsDrain policy; see MessageQueueOptions.

Returns

MessageQueue

Overrides

BoundedBuffer.constructor

Methods

clear()

clear(): void;

Defined in: primitives/bounded-buffer.ts:235

Drop every buffered item. Does not reset dropped / highWater.

Returns

void

Inherited from

BoundedBuffer.clear


drain()

drain(): Message[];

Defined in: primitives/bounded-buffer.ts:228

Remove and return buffered items per mode: the single oldest item for "one-at-a-time", or every buffered item for "all". Returns an empty array when empty — safe to pass directly as a drain hook.

Returns

Message[]

The drained items in FIFO order.

Inherited from

BoundedBuffer.drain


push()

push(...items): PushResult<Message>;

Defined in: primitives/bounded-buffer.ts:186

Push one or more items at the back of the buffer, applying the OverflowPolicy per item when at capacity.

Parameters

ParameterTypeDescription
...itemsMessage[]The item(s) to push, in order.

Returns

PushResult<Message>

A PushResult accounting for every pushed item.

Inherited from

BoundedBuffer.push

Properties

PropertyTypeDescriptionInherited fromDefined in
modeDrainModeDrain policy — mutable so a caller can switch one-at-a-time/all at runtime.BoundedBuffer.modeprimitives/bounded-buffer.ts:143

On this page