> ## Documentation Index
> Fetch the complete documentation index at: https://icrl.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ReActLoop

> ReAct-style agent loop with planning, reasoning, and acting

## Constructor

```ts theme={null}
new ReActLoop(llm: LLMProvider, retriever: TrajectoryRetriever, options: ReActLoopOptions)
```

## Options

`ReActLoopOptions` includes:

* `planPrompt`, `reasonPrompt`, `actPrompt`
* `maxSteps` (default: 30)
* `onStep`
* `maxGoalChars`, `maxPlanChars`, `maxObsChars`, `maxReasoningChars`

## Prompt Placeholders

* Plan: `{goal}`, `{examples}`
* Reason: `{goal}`, `{plan}`, `{observation}`, `{history}`, `{examples}`
* Act: `{goal}`, `{plan}`, `{reasoning}`, `{history}`, `{examples}`

## Methods

```ts theme={null}
await loop.run(env, goal);
```

Returns a `Trajectory` with `goal`, `plan`, `steps`, `success`, `metadata`.

## StepContext

Internal type for step formatting:

```ts theme={null}
interface StepContext {
  goal: string;
  plan: string;
  observation: string;
  reasoning: string;
  history: Step[];
  examples: StepExample[];
}
```
