Skip to slide
010 / 170

CH 01 · What Is an Agent Harness? · 10/12

Read as one page

Read the source yourself

Read these in order. Every link is the commit this chapter quoted.

  1. Three protocols, then the glue. Start at mini-swe-agent src/minisweagent/__init__.py, including the short Agent protocol under the two you already saw. Read query and _query in models/litellm_model.py, then execute through _check_finished in environments/local.py. Finish with step in agents/default.py. You want the agent to call the model, then the environment.
  2. The same split, as crates. Re-open the two slices of Codex codex-rs/Cargo.toml. Then read core/Cargo.toml until you have found codex-api, codex-execpolicy, and codex-hooks. Then the first screen of linux-sandbox/README.md for bubblewrap and seccomp.
  3. A generic loop, filled in by a coding harness. Re-read the new Agent({ block in pi packages/coding-agent/src/core/sdk.ts. Then createInitialSystemMessage in packages/ai/src/utils/transcript.ts, and initialActiveToolNames earlier in the same sdk.ts. The assignment this.agent.state.tools = declared is at line 1623. The package readme packages/agent/README.md draws the same path: transformContext, then convertToLlm, then the model.
  4. One product, several harnesses. Re-read the contract in OpenClaw src/agents/harness/types.ts. Then runAttempt in builtin-openclaw.ts, and supports plus runAttempt in extensions/codex/harness.ts. Finish in selection-decision.ts, where a forced openclaw runtime and an auto selection that found no plugin both end at the built-in harness.

Exercise: In Codex, open codex-rs/execpolicy/tests/basic.rs and find justification_is_attached_to_forbidden_matches. The rule's pattern is only ["rm"], the decision is forbidden, and the command under test is rm -rf plus a path. Write down why a one-token prefix catches the rest of that command. That test is exercising the permission layer the Harness class stores in permissions.

Finished this idea?

Your learning progress stays in this browser.