How windcherry/mini-openclaw works
1. Overall shape
- This repo is a Python command-line agent skeleton.
- The core architecture is a loop-based agent that sends state to an LLM backend, receives tool calls, executes tools locally or via plugins, then feeds results back until the task is done.
2. Entry point and orchestration
- agent/cli.py is the user-facing entry point for running the agent from the terminal.
- agent/loop.py is the central controller: it owns the turn-by-turn reasoning/execution cycle.
- agent/context.py likely holds the conversation/task state that is accumulated and passed through the loop.
3. Model/backend boundary
- backend/ is the abstraction for talking to the model provider.
- backend/client.py is the real API client path; the README says it is set up for a DeepSeek-style backend.
- backend/server.py and backend/fake_backend.py suggest two modes: a real serving layer and a local/mock backend for self-checks or development without external API calls.
- This boundary separates “agent logic” from “how the model is reached.”
4. Prompt rendering and tool-call parsing
- prompt/render.py is the formatting layer that turns agent state, messages, and available tools into the model prompt.
- This layer is important because the model must be told both the current task context and the tool schema.
- The repo README implies there is also parsing of model output into structured tool calls, so prompt handling is a dedicated subsystem rather than embedded in the loop.
5. Local tool execution layer
- tools/ contains the built-in actions the agent can invoke.
- tools/base.py is the common interface/contract for tools.
- tools/fs.py, tools/shell.py, and tools/more_tools.py indicate a split between filesystem operations, shell/command execution, and additional utility tools.
- Architecturally, this is the “actuator” layer: it takes structured tool requests and performs side effects on the local machine.
6. MCP integration boundary
- mcp/ is a separate subsystem for connecting to external tool servers using the Model Context Protocol.
- mcp/client.py and mcp/echo_server.py imply a client that can talk to third-party or local MCP servers, plus a minimal test/demo server.
- In the architecture, MCP tools sit alongside built-in tools, but they are sourced from external processes rather than from the repo’s own Python tool modules.
7. Skills as domain plugins
- skills/ is a plugin-like content layer for reusable domain knowledge or task procedures.
- skills/example-skill/SKILL.md shows that skills are file-based and markdown-described, not code-heavy.
- skills/loader.py is the discovery/loading mechanism, so skills can be injected into the agent without changing the core loop.
- This gives the agent extensibility at the knowledge/workflow level, distinct from tools.
8. Evaluation subsystem
- eval/tasks.py and eval/metrics.py form a standalone evaluation harness.
- This subsystem is used to measure agent behavior against task sets and compute metrics, likely supporting the repo’s day-by-day milestone validation.
- It is logically separate from runtime execution: it judges the agent rather than participating in normal tasks.
9. Data flow through a single task
- User request enters agent.cli.
- agent.loop builds context, renders prompts, and sends them to backend.
- The backend returns either a final answer or a structured tool request.
- Tool requests are dispatched to built-in tools/, MCP tools, or skill-backed behavior.
- Results are appended to context and sent back through the loop until completion.
10. Control and safety implications
- The README explicitly frames the project as having a future “security layer” for permissions, sandboxing, and prompt-injection defense.
- Even if not fully implemented yet, the architecture already anticipates a boundary between the model’s requests and the actual side effects performed by tools.
- That means tool dispatch is the natural enforcement point for safety checks.
11. Development/runtime characteristics
- Everything is Python-based, with the README recommending Python 3.11.
- The agent side is lightweight and command-line driven; there is no obvious web frontend in this repo.
- External dependencies are mainly the model API client and any MCP servers the agent connects to.
12. How to draw the diagram
- Draw one central loop box for agent/loop.py.
- Connect it upward to backend/ for model inference.
- Connect it downward to a tool dispatcher that fans out to tools/, mcp/, and skills/.
- Add prompt/ and agent/context.py as supporting layers feeding the loop.
- Put eval/ off to the side as a validation harness rather than part of the runtime path.
Main entry points: loop.py Loop · base.py Tool base · render.py Render · tasks.py Tasks
Components 18
Agent runtime
CLI entrypoint, loop, and shared task state.
- CLI · Terminal entrypoint for running the agent.
agent/cli.py - Loop · Main turn-by-turn controller for reasoning and execution.
agent/loop.py - Context · Conversation and task state carried through the loop.
agent/context.py - Agent prompts · Agent-facing prompt templates and prompt constants.
agent/prompts.py
Model backend
Interfaces for reaching the LLM and local backend modes.
- Client · Primary API client for the model provider.
backend/client.py - Server · Serving-side backend entry for model access or local hosting.
backend/server.py - Fake backend · Local mock backend for development and self-checks.
backend/fake_backend.py
Prompting
Prompt rendering and message/schema preparation.
- Render · Formats state, messages, and tool schemas into model input.
prompt/render.py
Execution tools
Built-in local tools and external tool integration.
- Tool base · Shared interface and contract for executable tools.
tools/base.py - Filesystem · File and path operations exposed to the agent.
tools/fs.py - Shell · Command execution and shell-based actions.
tools/shell.py - Extra tools · Additional built-in utility tools.
tools/more_tools.py - MCP client · Connects the agent to external MCP tool servers.
mcp/client.py - Echo server · Minimal local MCP server for testing and examples.
mcp/echo_server.py
Skills
File-based reusable task knowledge and loaders.
- Skill loader · Discovers and loads file-based skills into the agent.
skills/loader.py - Example skill · Markdown skill example showing the file-based skill format.
skills/example-skill/SKILL.md
Connections 21
- CLI → Loop: starts · CLI launches the main agent loop.
- Loop → Context: reads/writes · Loop maintains and updates task state.
- Loop → Agent prompts: uses · Loop relies on agent prompt templates.
- Loop → Render: renders · Loop asks the prompt layer to build model input.
- Render → Context: consumes · Prompt rendering uses accumulated context.
- Render → Tool base: describes · Prompt rendering includes available tool schema.
- Loop → Client: queries · Loop sends prompts to the primary model client.
- Loop → Fake backend: can swap · Development mode can use the fake backend.
- Client → Server: served by · Client path can target a server-side backend.
- Loop → Filesystem: dispatches · Structured tool calls can perform filesystem actions.
- Loop → Shell: dispatches · Structured tool calls can execute shell actions.
- Loop → Extra tools: dispatches · Loop can invoke additional built-in tools.
- Tool base → Filesystem: implements · Filesystem tool follows the shared tool contract.
- Tool base → Shell: implements · Shell tool follows the shared tool contract.
- Tool base → Extra tools: implements · Extra tools follow the shared tool contract.
- Loop → MCP client: delegates · Loop can route tool requests to MCP servers.
- MCP client → Echo server: connects · Client can talk to local or external MCP servers.
- Skill loader → Example skill: loads · Loader discovers markdown skill content.
- Loop → Skill loader: injects · Loaded skills augment the agent's behavior.
- Tasks → Metrics: scores with · Evaluation tasks are measured using metrics.
- Tasks → Loop: exercises · Evaluation harness drives the runtime loop.