CH 01 · What Is an Agent Harness? · 10/12
Read as one pageRead the source yourself
Read these in order. Every link is the commit this chapter quoted.
- Three protocols, then the glue. Start at mini-swe-agent
src/minisweagent/__init__.py, including the shortAgentprotocol under the two you already saw. Readqueryand_queryinmodels/litellm_model.py, thenexecutethrough_check_finishedinenvironments/local.py. Finish withstepinagents/default.py. You want the agent to call the model, then the environment. - The same split, as crates. Re-open the two slices of Codex
codex-rs/Cargo.toml. Then readcore/Cargo.tomluntil you have foundcodex-api,codex-execpolicy, andcodex-hooks. Then the first screen oflinux-sandbox/README.mdfor bubblewrap and seccomp. - A generic loop, filled in by a coding harness. Re-read the
new Agent({block in pipackages/coding-agent/src/core/sdk.ts. ThencreateInitialSystemMessageinpackages/ai/src/utils/transcript.ts, andinitialActiveToolNamesearlier in the samesdk.ts. The assignmentthis.agent.state.tools = declaredis at line 1623. The package readmepackages/agent/README.mddraws the same path:transformContext, thenconvertToLlm, then the model. - One product, several harnesses. Re-read the contract in OpenClaw
src/agents/harness/types.ts. ThenrunAttemptinbuiltin-openclaw.ts, andsupportsplusrunAttemptinextensions/codex/harness.ts. Finish inselection-decision.ts, where a forcedopenclawruntime 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.