The Complete Guide to Building and Deploying Autonomous AI Agents with Hermes 3

Hermes 3 delivers reliable tool calling via open source, covering the full pipeline from local deployment to production hardening for autonomous agents.
This article explains how to build autonomous AI Agents with Hermes 3, a Nous Research fine-tune of Llama 3.1. Hermes 3 achieves deterministic function calling through structured `<tool_call>` tags and is compatible with OpenAI's tool_calls schema, avoiding common issues in base models like fabricated parameters and broken JSON, while offering sizes from 8B to 405B. It covers two deployment paths—Ollama for local use and vLLM for production—and fully demonstrates a Python agent implementation with tool schema definitions, multi-turn loops, and exception-based self-correction. For long-horizon tasks, it proposes three advanced architectural techniques: scratchpad reasoning, a sliding memory window, and failure self-correction, and explains integration via LangChain and CrewAI. Finally, it outlines production hardening essentials from pydantic parameter validation, hard timeouts, and iteration caps to OpenTelemetry/Langfuse observability.
The breakthrough in tool-calling capabilities of open-source large models is reshaping the landscape of AI Agent development. Hermes 3 (Nous Research's fine-tune based on Llama 3.1) is purpose-built for agentic tasks, supporting multi-turn reasoning, structured JSON generation, and native tool calling—letting developers build reliable autonomous agents without relying on expensive closed-source APIs.

Why Hermes 3 Is Suited for Building Autonomous Agents
Most base LLMs frequently stumble when confronted with strict API contracts: fabricating missing parameters, breaking JSON schemas midway, or failing to self-correct after receiving tool errors. Hermes 3's advantages lie in:
- Deterministic tool calling: Formats function calls using the structured
<tool_call>...</tool_call>tags, drastically reducing the probability of JSON syntax corruption - Neutral alignment and deep steerability: Strictly follows system prompts without injecting extraneous refusal behaviors—ideal for domain-specific automation
- Hardware scalability: Offers multiple parameter sizes—8B (suited to local Macs or a single consumer GPU) and 70B/405B (suited to enterprise clusters)
Understanding Hermes's Native Tool Calling Protocol
Under the hood, Hermes uses XML-like tags to organize an agent's reasoning and actions. The model outputs <tools> definitions and <tool_call> invocation blocks, which inference engines like vLLM and Ollama transparently convert into the standard OpenAI-compatible tool_calls schema.
This means developers gain the reliability of an open-source fine-tuned model without falling into vendor lock-in.
OpenAI-compatible tool_calls schema refers to the set of function-calling data structures defined in the OpenAI Chat Completions API: on the request side, function signatures described by JSON Schema are passed in via the tools parameter; on the response side, the model returns a tool_calls array, each item containing id, type, and function.name / function.arguments (arguments being a JSON string). This schema has become the de facto standard, with orchestration frameworks like LangChain, CrewAI, and LlamaIndex all parsing tool calls based on it. Hermes 3 uses XML-like <tool_call> tags during generation, and the inference engine (vLLM's --tool-call-parser hermes, Ollama's built-in parser) handles converting these tags into the aforementioned schema—so upper-layer code doesn't need to be aware of underlying format differences and can directly reuse existing OpenAI ecosystem clients.
Environment Setup and Inference Engine Selection
Local Deployment: Ollama
Ollama is the fastest way to run Hermes on macOS or consumer-grade Linux:
curl -fsSL https://ollama.com/install.sh | sh
ollama run hermes3:8b
By default, it serves an OpenAI-compatible API at http://localhost:11434/v1.
High-Throughput Production Deployment: vLLM
On NVIDIA GPUs (A10G, A100, RTX 4090), use vLLM for continuous batching and PagedAttention optimization:
pip install vllm
python -m vllm.entrypoints.openai.api_server \
--model nousresearch/Hermes-3-Llama-3.1-8B \
--port 8000 --enable-auto-tool-choice \
--tool-call-parser hermes --max-model-len 8192
PagedAttention is the attention memory management mechanism proposed by vLLM, inspired by virtual memory paging in operating systems: it divides the KV Cache into fixed-size blocks and uses a block table to map logical to physical locations, thereby eliminating memory waste caused by pre-allocating maximum sequence lengths and enabling physical block sharing of identical prefixes (such as the system prompt) across different requests. Continuous batching, meanwhile, dynamically evicts completed sequences and inserts new requests after each forward iteration, keeping the GPU fully utilized and improving throughput several times over compared to static batching. For agent scenarios, these two optimizations are especially critical: multi-turn tool calling rapidly inflates context, PagedAttention reduces the memory overhead of long contexts, and continuous batching suits the load characteristics of many concurrent sessions executing in an interleaved fashion.
Building an Agent Loop from Scratch (Python)
The core logic is a multi-turn loop: send the conversation history and tool schemas to the model; when the model returns tool_calls, execute the corresponding functions, inject the results into the conversation, and proceed to the next round—until the model no longer requests tool calls.
The full hermes_agent.py example from the original article demonstrates an inventory query scenario:
- Defines two tools:
get_server_loadandquery_database - Describes tool signatures via
TOOL_SCHEMAS - The main loop sets
max_iterations=5andtemperature=0.2 - Captures tool execution exceptions and returns them to the model as
{"error": ...}
The key design point is that exceptions don't interrupt the loop but are fed back to Hermes as tool results, giving it a chance to self-correct.
Advanced Architecture: State Machines and Memory Management
A simple loop can only handle linear tasks. For long-horizon operations, you need to introduce:
- Scratchpad reasoning: Encourage Hermes to output its internal thought process before calling tools, reducing random decisions
- Sliding memory window: When an agent runs 15+ rounds of tool calls, context grows exponentially. Old tool messages beyond N rounds need to be trimmed or summarized while preserving system instructions and the user's original prompt
- Failure self-correction: When a tool returns
404 Not FoundorSQL Syntax Error, Hermes has the intrinsic ability to analyze the traceback and generate a corrected call
Scratchpad reasoning in the agent context refers to having the model first output intermediate reasoning text in a designated area before taking formal action—such as task decomposition, hypotheses to be verified, and candidate tools with their parameter drafts—then generating the final tool call based on that. This approach originates from the ReAct paradigm, and its value lies in making implicit decisions explicit: on one hand, it provides an auditable reasoning trace for troubleshooting erroneous calls; on the other, it forces the model to complete a self-check before issuing side-effect operations, significantly reducing the probability of random or impulsive decisions. In implementation, this is typically done by specifying a segmented Thought: / Action: format in the system prompt, or by wrapping with a dedicated <scratchpad> tag, and stripping that portion during parsing so it isn't sent to downstream tool execution.
Framework Integration: LangChain and CrewAI
If your team already uses an orchestration framework, Hermes can be integrated seamlessly via standard connectors. For LangChain integration, simply point ChatOpenAI's base_url to the local endpoint, set model to hermes3:8b, and bind tools via create_tool_calling_agent.
This compatibility means existing OpenAI ecosystem code can switch to Hermes with virtually no changes.
Production Hardening and Observability
Deploying autonomous agents to production requires safety controls:
- Deterministic output validation: Wrap parameter payloads with pydantic schemas to reject malformed calls before they reach production databases or third-party webhooks
- Rate limiting and execution budget: Configure hard timeouts (e.g., 30 seconds) and iteration caps (K ≤ 8) to avoid infinite recursion
- Trace logging: Integrate OpenTelemetry or Langfuse to monitor latency, token consumption, and prompt drift
For critical mutating operations (deleting records, sending emails), always add a human-in-the-loop verification step.
human-in-the-loop (HITL) verification refers to routing actions to human review and confirmation before an agent executes irreversible or high-impact operations. There are three common implementation approaches: first, tool-level interception—writing high-risk functions (deletion, payment, sending messages) to a pending approval queue and returning a pending_approval status, then resuming the loop after an external approval system calls back; second, policy-layer whitelisting—using declarative rules to mark which tools require human confirmation; third, interaction-layer confirmation dialogs—suitable for scenarios with a frontend. In state machine frameworks like LangGraph, you can directly insert an interrupt before critical nodes, persisting the current state to await human resumption. HITL is essentially using deterministic human judgment as the final safety gate for probabilistic model output.
Summary
Hermes 3 frees developers from having to choose between data privacy and hefty API bills. With local quantized inference plus a robust function-calling architecture, you can build self-healing agent pipelines that truly get work done. Next steps: spin up Hermes locally with Ollama, connect it to your own database or API, and then progressively add human verification steps.
Related articles

JobRunner MCP Server: AI Agents Can Now Fix Failed Java Jobs
JobRunner launches an open-source MCP server enabling AI agents to view cluster status, diagnose failures, and recover Java jobs—incident response from any cloud coding environment or existing agent.

MLAI Digital Launches 9 Security Agents: MCP Server Safeguards the Full Lifecycle of Agentic AI
MLAI Digital launches Security MCP Server with nine built-in specialized security agents covering vulnerability discovery, attack simulation, prompt injection detection, API and infrastructure assessment, and accelerated remediation—embedding security validation across the full Agentic AI lifecycle from development to production.

Running Isaac Lab on H100 GPUs: Exploring Better Approaches
Exploring optimization methods for running Isaac Lab on NVIDIA H100 GPUs, including MIG configuration, mixed precision, TensorRT acceleration, and community experience to improve robotics simulation and reinforcement learning efficiency.