Introduction
Every non-trivial Hermes turn is a small loop: the model decides what to do, emits a tool call, Hermes runs it, the result comes back, and the model decides again. Understanding this loop is the difference between treating Hermes as a chat box and treating it as a programmable agent.
Key Concepts
- Tool loop: The cycle of decide, call, execute, return, repeat that drives every multi-step Hermes task.
- Step: One iteration of the loop. A single user message may produce dozens of steps.
- Termination: The loop ends when the model produces a final text response with no tool call, or when a hard limit (steps, tokens, time) is reached.
Real World Context
When you ask Hermes to find all TODOs in this repo and group them by file, the work decomposes into many small calls: a search_files to locate TODOs, a read_file or two to inspect context, possibly a patch if you asked for fixes. Each is a step in the loop. The loop is what makes the agent feel autonomous: you make one request, and the model self-drives through ten tool calls without further input.
Deep Dive
A single cycle of the loop has four moments:
- Decide. The model reads the conversation so far, including any previous tool results, and decides whether more work is needed. If yes, it picks a tool.
- Call. The model emits a structured tool call: a name plus an argument object that matches the tool's schema.
- Execute. Hermes validates the call (does the tool exist, do the arguments fit the schema, is the action permitted?) and then runs the implementation. The result is captured.
- Return. Hermes appends the tool result to the conversation. The model now sees it and goes back to step 1.
This continues until the model produces a final text response with no tool call.
textUser request │ ▼ ┌─────────────────────┐ │ Model decides │ ◄─────────────┐ └─────┬───────────────┘ │ │ emits tool_call │ ▼ │ ┌─────────────────────┐ │ │ Hermes executes │ │ └─────┬───────────────┘ │ │ returns tool_result │ └───────────────────────────────┘ (loop until no tool_call) │ ▼ Final response
The key property of this loop is that the model is in the driver's seat. Hermes does not decide which tool to run next. It only decides whether to allow the call the model requested. If you want the agent to behave differently, the lever is almost always either the available toolset or the system prompt, not the loop itself.
Common Pitfalls
- Expecting parallel tool calls automatically: Hermes does run independent calls in parallel when the model emits them in one batch, but most loops are sequential. Plan accordingly.
- Losing track of step count on long tasks: A loop that runs forty steps will eat context. Use
/compactor break the task up if you see the status bar climbing.
Best Practices
- Read tool calls in the transcript: When debugging odd behavior, scroll back and read each
tool_callandtool_resultpair. The error is almost always one of those four moments. - Trust the loop for multi-step work: Resist the urge to micromanage. Ask once, let the loop run, and only intervene if it stalls or goes off course.
Summary
- Every Hermes turn is a loop: decide, call, execute, return.
- The loop terminates when the model produces a final text response with no tool call.
- The model drives the loop; Hermes executes and validates.
- Most agent behavior is shaped by the available toolset and the system prompt, not by the loop mechanism.
Code Examples
Step 1: model decides → 'I need to list the files'
Step 1: tool_call → terminal({ command: 'ls -la' })
Step 1: tool_result → 'total 16\ndrwxr-xr-x ...'
Step 2: model decides → 'I should read package.json'
Step 2: tool_call → read_file({ path: 'package.json' })
Step 2: tool_result → '{ "name": "my-app", ... }'
Step 3: model decides → 'I have enough info, write the summary'
Step 3: (no tool call, just a final text response)