Chapter 12

The Full Picture

The complete journey from user input to Agent response

Scenario: User says "Fix the bug in login.py"

Let's trace this request through every step in OpenHarness:

Step 1: CLI Entry Point

The user types a request in the terminal. The CLI receives the text, wraps it into a User Message, and passes it to the Engine. 📂 Relevant code: cli.py → parse CLI arguments and input

Step 2: Engine Initialization

The Engine prepares everything the Agent Loop needs: • Load the system prompt • Inject memories from MEMORY.md • Prepare the tool list (built-in + MCP) • Initialize the permission checker 📂 Relevant code: engine/query_engine.py → assemble runtime context

Step 3: Agent Loop — Round 1

The message is sent to the LLM (via the Anthropic API). The LLM analyzes the request and decides to read the file first: Returns: tool_use → Read(file_path="login.py") 📂 Relevant code: engine/query.py → run_query loop

Step 4: Hook + Permission Check

Before executing the Read tool: 1. PreToolUse Hook is triggered → logs the action 2. PermissionChecker checks → Read is a read-only operation, auto-passes in default mode 📂 Relevant code: hooks/executor.py + permissions/checker.py

Step 5: Tool Execution

The Read tool executes: • Opens the login.py file • Reads the content • Wraps it in a ToolResult and returns The result is added to the message history. 📂 Relevant code: tools/file_read.py → execute()

Step 6: Agent Loop — Round 2

The LLM sees the file content and finds a reversed condition on line 42. It decides to fix it: Returns: tool_use → Edit(file_path="login.py", old_string="if user == None", new_string="if user is not None") This time, Edit is a write operation. In default mode: • Hook fires • Permission check → requires user confirmation • User sees a confirmation prompt in the terminal and clicks "Allow" • The Edit tool executes the modification

Step 7: Agent Loop — Round 3

The LLM sees the edit succeeded and decides to run tests to confirm: Returns: tool_use → Bash(command="python -m pytest test_login.py") After user confirmation, the tests run and pass.

Step 8: Loop Ends

The LLM considers the task complete and returns a final response (stop_reason="end_turn"): "Fixed the bug on line 42 of login.py. The issue was that `if user == None` should be `if user is not None`. Tests pass." The Agent Loop ends, and the result is displayed in the terminal.

Step 9: Memory (Optional)

If something worth remembering was discovered during the process (like a recurring bug pattern), the Agent writes it to a memory file for future conversations.

Full Flow Summary

Let's review all the subsystems involved: 1. CLI / UI → User interface 2. Engine → Agent Loop core cycle (3 rounds) 3. API → Communication with the LLM (3 API calls) 4. Tools → Read, Edit, Bash (3 tools) 5. Hooks → PreToolUse / PostToolUse (before and after each tool) 6. Permissions → Read auto-passes, writes need confirmation (2 confirmations) 7. Memory → Optional cross-session memory See? A simple "fix a bug" request involved most of OpenHarness's subsystems. That's the power of the Harness — all components work together to let the Agent accomplish complex tasks.
📌 Key Takeaway
Everything Comes Together
Congratulations on completing all 12 chapters! Now you understand: what an Agent is, the Harness's five capabilities, the Agent Loop cycle, the tool system, permission control, Hook lifecycle, on-demand skills loading, memory persistence, the MCP standard protocol, multi-Agent collaboration, and how they all work together in a real request.

What's Next?

Now that you have a comprehensive understanding of OpenHarness, consider: 🔍 Read the Source Code OpenHarness is only about 11,700 lines of code. Reading it in the order of this course will feel very natural. 🔧 Build a Custom Tool Inherit from BaseTool, implement your own tool, and register it. 📚 Write a Skill Create a custom skill file for your project or team. 🌐 Build an MCP Server Wrap a service you frequently use as an MCP Server so Agents can use it directly. 🤝 Contribute OpenHarness is open source — contributions of code and ideas are welcome.
🧠 Check Your Understanding
In the "fix a bug" full flow, how many rounds did the Agent Loop iterate?
🧠 Check Your Understanding
In default permission mode, which operations in this flow required user confirmation?