Files
openclaw-skill/openclaw-knowhow-skill/docs/agents/agent-loop.md
Selig 4c966a3ad2 Initial commit: OpenClaw Skill Collection
6 custom skills (assign-task, dispatch-webhook, daily-briefing,
task-capture, qmd-brain, tts-voice) with technical documentation.
Compatible with Claude Code, OpenClaw, Codex CLI, and OpenCode.
2026-03-13 10:58:30 +08:00

30 lines
1.5 KiB
Markdown

# Agent Loop Documentation - OpenClaw
## Overview
The Agent Loop in OpenClaw represents a complete agent execution cycle, encompassing message intake through final reply persistence. An agentic loop is the full run of an agent: intake, context assembly, model inference, tool execution, streaming replies, and persistence.
## Key Components
**Entry Points:**
The system accepts agent requests via Gateway RPC (`agent` and `agent.wait` commands) and CLI.
**Execution Flow:**
The process involves parameter validation, session resolution, metadata persistence, and model inference through the pi-agent-core runtime, which handles serialization and event streaming.
**Queueing System:**
Runs are serialized per-session to prevent concurrency issues. Runs are serialized per session key (session lane) and optionally through a global lane.
## Extension Mechanisms
OpenClaw provides two hook systems for customization:
1. **Internal Gateway Hooks** - Event-driven scripts for commands and lifecycle events (bootstrap, commands)
2. **Plugin Hooks** - Extension points including `before_agent_start`, `agent_end`, tool call interception, and message lifecycle events
## Operational Details
- **Timeout defaults:** 30 seconds for `agent.wait`; 600 seconds for agent runtime
- **Streaming:** Assistant deltas and tool events are emitted as separate streams
- **Reply handling:** Payloads are assembled from assistant text, tool summaries, and reasoning, with suppression of duplicate messaging tool outputs