# Reading an agent’s source

> Map an agent system from its code before you configure or trust it.

- Canonical: https://starkslab.com/learn/reading-agent-source
- Notes: 4 · Updated: 2026-11-24

## Read in this order

1. [How an AI Agent’s Basic Control Loop Runs in Python](https://starkslab.com/notes/ai-agent-basic-control-loop-python-source-trace.md): Inspect one execution of Federico Jan's Minimal Agent Framework at a pinned commit. Follow a local file read/write task from scripted model actions through tool validation, dispatch, state updates and final output; use trace events, deliberate halts and replay to build a worksheet readers can apply to another agent repository. (Guide; tested; 2026-10-14)
2. [OpenClaw Architecture Explained: Gateway, Sessions, Memory, and Tools](https://starkslab.com/notes/openclaw-architecture-explained.md): Skimmable OpenClaw system map covering the gateway, sessions, memory files, heartbeat and cron, and the execution layer from inbound message to action. (Explainer; 2026-04-25)
3. [OpenClaw WebSocket Gateway: Deterministic Routing and the connect.challenge Handshake](https://starkslab.com/notes/openclaw-gateway-architecture-why-presence-beats-intelligence.md): How the OpenClaw WebSocket gateway works, verified on a live 2026.10.10 gateway: the connect.challenge handshake, the 9-step binding cascade that routes every message to one session, and 33 channels. (Explainer; tested; 2026-02-17)
4. [OpenClaw Source Code Structure (2026): Core Folders, Gateway & Runtime Mapped](https://starkslab.com/notes/i-read-openclaws-source-code.md): OpenClaw source code, re-verified 5 Nov 2026 against main and the 2026.10.10 release: the core folder structure in one table, what changed since v1, real command output, and where each subsystem lives. (Source read; source read; 2026-02-08)

## Tools in these notes

- [Minimal Agent Framework](https://starkslab.com/tools/minimal-agent-framework.md)
- [OpenClaw](https://starkslab.com/tools/openclaw.md)

---

Starkslab index for agents: https://starkslab.com/llms.txt lists every page with its Markdown link.
