Aulafy
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.
TerminalCode
task:
  goal: "Añadir una validación sin romper API pública"
  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.

TerminalCode
# .agent/state.md
## Objetivo actual
Corregir validación de email sin cambiar contratos públicos.

## Decisiones
- No tocar base de datos.
- Mantener nombres de funciones exportadas.

## Evidencia
- npm run lint: pendiente
- npm test: pendiente

## Bloqueos
- Falta confirmar comportamiento con emails internacionales.

Circuit breakers for runaway loops

TerminalCode
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