An AI agent harness is the loop that runs tools for an LLM

An LLM takes a prompt and a list of , then returns either normal text or a . A tool definition tells the LLM what actions are available, such as reading a file, writing a file, or running a command. A can include arguments, such as the name of a file.

An is the program that keeps this process moving. It sends the prompt to the LLM, checks the response, runs the requested tool if there is a , and sends the tool result back to the LLM. If the response is normal text instead of a , the loop stops.

This simple loop is the core pattern behind such as Claude Code, opencode, and Codex, even though real systems add more layers on top.

Key points

  • An LLM receives a prompt and , then returns text or a .
  • describe actions like reading files, writing files, or running commands.
  • An runs the and sends the result back to the LLM.
  • The loop ends when the LLM returns normal text instead of another .
  • Longer loops and larger context can increase token use and cost.
Read original