Skip to content
Courses/Agents and automation/Local Multi-Agents, Memory, and Loops

Local Multi-Agents, Memory, and Loops

Running multiple agents in parallel does not automatically multiply intelligence. It also multiplies VRAM, RAM, CPU usage, logs, inconsistent states, and loop risk. Design guardrails before you design subagents.

  • Decide when local subagents are worth using.
  • Create persistent memory without turning it into a chaotic junk drawer.
  • Apply limits on steps, tools, time, and compute.

Start with narrow roles

  • Planner: decides the plan and success criteria; does not edit.
  • Retriever: fetches context from files, RAG, or documentation.
  • Executor: applies scoped changes.
  • Verifier: runs tests, reviews diffs, and detects regressions.
Terminal
task:
  goal: "Add validation without breaking the public API"
  max_total_steps: 16
  max_parallel_agents: 2
  memory_file: ".agent/state.md"

agents:
  planner:
    can_edit: false
    max_steps: 3
  executor:
    can_edit: true
    allowed_paths: ["src/", "tests/"]
    max_steps: 6
  verifier:
    can_edit: false
    commands: ["npm run lint", "npm test"]
    max_steps: 4

Minimal persistent memory

Memory should store decisions and state, not the entire chat. If you store noise, the agent will retrieve noise.

Terminal
# .agent/state.md
## Current goal
Fix email validation without changing public contracts.

## Decisions
- Do not touch the database.
- Keep exported function names.

## Evidence
- npm run lint: pending
- npm test: pending

## Blockers
- Need to confirm behavior with international emails.

Circuit breakers for runaway loops

Evaluate the trajectory, not just the answer

In multi-agent systems, a correct final answer can hide an expensive, fragile, or unsafe process. Save the decision sequence to know whether the system chose tools well, avoided useless steps, and asked for help when appropriate.

Terminal
trajectory_eval:
  task_id: "bugfix-142"
  final_result: "pass"
  checks:
    tool_use_accuracy: "ok"
    repeated_steps: 0
    unnecessary_agents: 1
    human_approval_used: true
    tests_run:
      - "npm test"
      - "npm run lint"
  decision: "works, but reduce planner+researcher to a single role"
Terminal
loop_guards:
  repeated_tool_call:
    same_tool_same_args: 2
    action: stop_and_summarize
  no_state_change:
    steps_without_new_evidence: 3
    action: ask_human
  compute_budget:
    max_runtime_minutes: 20
    max_gpu_memory_percent: 90
    action: pause
  failed_command:
    same_error: 2
    action: change_strategy_or_stop

Official sources

  • Hermes Agent documentation
  • LangGraph Docs
  • LangGraph Persistence
  • Model Context Protocol
Complete Aulafy mapSee how this lesson fits without leaving your path.

Complete Aulafy map

How all courses connect

This is not a checklist. Start with the foundation, choose an outcome, and go deeper only when your project needs more control.

  1. 1Understand
  2. 2Apply or build
  3. 3Operate with confidence
01

Choose an application

Turn the foundation into a visible outcome: a website, a business improvement, media, or an interactive experience.

Continue into the technical branch when you need to maintain code, data, or infrastructure.

02

Build with code

Prepare your environment, work with coding agents, and run models while keeping control of your projects.

This branch prepares you to design and operate reliable AI systems.

03

Take systems to production

Combine retrieval, agents, evaluation, security, deployment, and model adaptation when the problem requires it.

You do not need every course: choose the component your system needs and return as it grows.

View full catalogue