Skip to main content

Class: LoopController

Defined in: packages/agentos/src/orchestration/runtime/LoopController.ts:202

Configurable ReAct loop controller.

Drives a generate → act → observe cycle, delegating LLM inference and tool execution to the caller-provided LoopContext. The loop terminates when:

  1. The LLM returns no tool calls (natural stop), or
  2. maxIterations is exceeded, or
  3. A tool fails and failureMode is 'fail_closed'.

All intermediate events are yielded so callers can stream output to the user or record an audit trace.

Constructors​

Constructor​

new LoopController(): LoopController

Returns​

LoopController

Methods​

execute()​

execute(config, context): AsyncGenerator<LoopEvent>

Defined in: packages/agentos/src/orchestration/runtime/LoopController.ts:211

Execute the ReAct loop and yield LoopEvents.

Parameters​

config​

LoopConfig

Loop behaviour configuration.

context​

LoopContext

Callbacks to the underlying LLM/tool layer.

Returns​

AsyncGenerator<LoopEvent>

Yields​

Structured events for each phase of the loop.

Throws​

Only when failureMode === 'fail_closed' and a tool fails.