Skip to main content
OrcBot uses the ReAct (Reasoning + Acting) paradigm to autonomously solve tasks through iterative thought, action, and observation cycles.

What is ReAct?

ReAct is a prompt engineering pattern that gives language models the ability to:
  1. Think about what to do next (reasoning)
  2. Act by calling tools/functions
  3. Observe the results
  4. Re-reason based on observations
  5. Repeat until the task is complete
This is fundamentally different from single-shot LLM calls, where the model gives one answer and stops. ReAct enables agents to work through problems iteratively, just like a human would.

The Loop Implementation

The core loop is implemented in Agent.ts (lines 67-797). Here’s the simplified flow:

Step-by-Step Example

Let’s trace a real task: “Find the weather in Paris and send it to me on Telegram”

Step 0: Pre-Task Simulation

Before entering the loop, SimulationEngine creates a plan:
This plan is injected into the prompt to help the LLM stay on track.

Step 1: Reasoning

Prompt assembled by DecisionEngine:
LLM Response (Step 1):
Action: Agent executes web_search("weather Paris current temperature") Observation (saved to memory):

Step 2: Re-Reasoning

Prompt (Step 2):
LLM Response (Step 2):
Action: Agent executes send_telegram(123456789, "Weather in Paris: 8°C...") Observation (saved to memory):

Step 3: Completion

Prompt (Step 3):
LLM Response (Step 3):
Action: Agent marks action as completed and exits loop.

Loop Mechanics

Entry Conditions

The loop starts when:
  1. An action is popped from the ActionQueue
  2. Agent.runActionLoop() is called
  3. The action status is 'pending' or 'running'

Exit Conditions

The loop terminates when:
  1. Natural completion: LLM sets completed: true
  2. Max steps reached: Default is 15 steps (configurable via maxStepsPerAction)
  3. Max messages sent: Default is 10 (configurable via maxMessagesPerAction)
  4. Hard timeout: 30 minutes (configurable via actionTimeoutMs)
  5. Cancellation: User or system cancels the action

Step Budget (Dynamic)

OrcBot uses an LLM-based Task Complexity Classifier to adjust step budgets dynamically:
This prevents trivial tasks from wasting tokens on 15-step budgets, while giving complex tasks more room to work.

Memory Scope

Each step’s observations are saved with the action ID:
This allows the agent to:
  • See its own progress within the current task
  • Filter out unrelated memories from other actions
  • Clean up step memories after task completion

Step History Compaction

When step count exceeds 10, OrcBot automatically compacts history:
This prevents prompt bloat while preserving context continuity.

Guardrails

Before each tool execution, DecisionPipeline applies safety checks:

1. Deduplication

Prevents repeated identical tool calls within the same action:

2. Loop Detection

Blocks repetitive patterns (e.g., web_search → browser_navigate → web_search):

3. Cross-Channel Send Protection

Non-admin tasks can’t send to other channels:

4. Autonomy Delivery Policy

Heartbeat tasks can only send to allowed channels:

Termination Review

Before accepting completed: true, OrcBot runs a termination review to prevent premature exits:
Example termination block codes: See decision-pipeline.mdx for more details.

Transparency Nudges

If the agent works silently for too long, the prompt injects a nudge:
This prevents the “silent failure” UX issue where users think the agent crashed.

Special Loop Modes

Heartbeat Loop

Autonomous tasks (source: 'autonomy') skip redundant context loading:

Time Capsule Mode

High-intensity tasks with relaxed limits:
Only available to admin users. Useful for complex, time-bounded goals.

Lean Mode

Skip expensive context retrieval for simple tasks:
Automatically enabled for trivial tasks (e.g., “ping”).

Debugging the Loop

To trace loop execution: 1. Enable verbose logs:
2. Inspect step memories:
3. Watch live in TUI:
4. Check pipeline blocks:

Performance Notes

Token costs per step:
  • System prompt: ~2,500 tokens (cached after step 1)
  • Step history: ~500-2,000 tokens (grows with step count, compacted at 10+)
  • Tool output: ~500-5,000 tokens (truncated if > 10 KB)
  • LLM response: ~200-500 tokens
Total per action (average): 8-12 steps × 5,000 tokens = 40,000-60,000 tokens Optimization tips:
  • Use compactSkillsPrompt: true to reduce skills list by 60%
  • Enable step compaction (default threshold: 10 steps)
  • Set memoryContentMaxLength to 1500 (default) to truncate large observations
  • Use lean mode for simple tasks

Further Reading