Agents

Cette page fournit une vue d'ensemble des différents types d'agents disponibles dans OpenClaw et comment les orchestrer.

Types d'agents

1. Agent principal (Main Agent)

L'agent par défaut pour les conversations directes :

Caractéristiques:

  • Session persistante
  • Accès complet au workspace
  • Mémoire long terme (MEMORY.md)
  • Tous les outils disponibles

Usage:

# CLI
openclaw agent "What's on my calendar today?"

# Telegram/Discord
> Hey, can you check my emails?

2. Subagents (Agents délégués)

Agents spawned pour des tâches spécifiques :

Caractéristiques:

  • Lifecycle limité (termine après tâche)
  • Contexte restreint
  • Pas d'accès MEMORY.md
  • Rapport final au main agent

Usage:

# Spawner un subagent
openclaw agent --spawn --label "translate-docs" "Translate 12 pages from EN to FR"

# Le main agent reçoit une notification à la fin

Voir Subagents

3. Agents de groupe (Group Agents)

Agents participant à des conversations de groupe :

Caractéristiques:

  • Écoute passive (reçoit tous les messages)
  • Répond intelligemment (quand mentionné ou pertinent)
  • Comportement social approprié
  • Pas de spam

Configuration:

channels:
  telegram:
    groupBehavior: "smart"  # smart | always | mention-only

4. Agents spécialisés (Specialized Agents)

Agents configurés pour des domaines spécifiques :

Exemples:

  • Code reviewer : Analyse de code, PRs
  • Customer support : Réponses FAQ, tickets
  • Data analyst : Analyse de données, graphiques
  • Social media : Gestion Twitter, posts

Configuration:

agents:
  code-reviewer:
    model: "anthropic/claude-opus-4"
    thinking: "high"
    skills: ["exec", "web_search"]
    context:
      files: ["CODING_STANDARDS.md", "PR_TEMPLATE.md"]
  
  customer-support:
    model: "anthropic/claude-sonnet-4"
    thinking: "low"
    skills: ["web_search", "message"]
    context:
      files: ["FAQ.md", "SUPPORT_POLICIES.md"]

Orchestration multi-agents

Délégation de tâches

Le main agent peut spawner des subagents :

User: "Translate these 12 docs and deploy the website"
  ↓
Main Agent:
  ├─> Subagent A: "Translate 12 docs" (parallel)
  ├─> Subagent B: "Build website" (sequential after A)
  └─> Main: Deploy and notify user

Communication inter-agents

Les agents peuvent communiquer via :

  • Fichiers partagés : workspace/shared/
  • Message passing : RPC interne
  • Event streams : PubSub

Coordination

Patterns d'orchestration :

  1. Sequential : A termine → B démarre
  2. Parallel : A et B en même temps
  3. Conditional : Si A réussit → B, sinon → C
  4. Loop : Répéter jusqu'à condition

Configuration

agents.yaml

Définir des agents personnalisés :

agents:
  # Agent par défaut
  default:
    model: "anthropic/claude-sonnet-4"
    timeoutSeconds: 600
    thinking: "low"
    verbose: false
  
  # Agent spécialisé code
  code-assistant:
    model: "anthropic/claude-opus-4"
    thinking: "high"
    skills:
      - exec
      - web_search
      - browser
    workspace: "~/projects"
    context:
      files:
        - "CODING_STANDARDS.md"
        - "ARCHITECTURE.md"
  
  # Agent support client
  support-bot:
    model: "anthropic/claude-sonnet-4"
    thinking: "low"
    skills:
      - web_search
      - message
    context:
      files:
        - "FAQ.md"
        - "SUPPORT_POLICIES.md"
    rules:
      - "Always be polite and helpful"
      - "Escalate to human if uncertain"

Lancer un agent spécifique

# CLI
openclaw agent --profile code-assistant "Review this PR"

# RPC
gateway.rpc('agent', {
  profile: 'support-bot',
  message: 'Help with billing question'
})

Gestion des agents

Lister les agents actifs

openclaw agents ls

# Output:
# AGENT ID          TYPE      STATUS   SESSION
# main              main      active   agent:main:main
# translate-docs    subagent  running  agent:main:subagent:abc123
# code-review       main      idle     agent:code-assistant:main

Arrêter un agent

# Arrêter un agent spécifique
openclaw agents stop <agent-id>

# Arrêter tous les subagents
openclaw agents stop --all --type subagent

Logs d'agent

# Logs en temps réel
openclaw logs --follow --agent <agent-id>

# Logs d'erreurs
openclaw logs --level error --agent <agent-id>

Patterns avancés

1. Pipeline de traitement

Input → Agent A (extract) → Agent B (transform) → Agent C (load)

2. Consensus multi-agents

Question → [Agent A, Agent B, Agent C] → Vote/Consensus → Réponse

3. Hiérarchie d'agents

Manager Agent
  ├─> Worker Agent 1
  ├─> Worker Agent 2
  └─> Worker Agent 3

4. Agent avec feedback loop

Agent → Action → Observe → Learn → Adjust → Action

Hooks multi-agents

Coordonner via hooks :

// Gateway hook: agent_spawned
export function onAgentSpawned(ctx) {
  console.log('Subagent spawned:', ctx.agentId);
  
  // Notifier autre système
  await notifyMonitoring({
    type: 'agent_spawned',
    agentId: ctx.agentId,
    task: ctx.task
  });
}

// Gateway hook: agent_completed
export function onAgentCompleted(ctx) {
  console.log('Agent completed:', ctx.agentId);
  
  // Trigger next step
  if (ctx.success) {
    await spawnNextAgent(ctx.nextTask);
  }
}

Limites et considérations

Ressources

  • Chaque agent consomme : CPU, RAM, tokens
  • Limites par instance : Configurable
  • Rate limiting : API providers

Coordination

  • Pas de deadlocks : Éviter attentes circulaires
  • Timeouts : Toujours définir timeouts
  • Error handling : Gérer échecs de subagents

Coûts

  • Tokens cumulés : N agents = N × tokens
  • Surveillance : Monitorer usage par agent
  • Budget : Définir limites par agent/tâche

Monitoring

Dashboard

# Ouvrir dashboard
openclaw dashboard

# Vue agents
http://localhost:3000/agents

Métriques

  • Nombre d'agents actifs
  • Token usage par agent
  • Latence moyenne
  • Taux d'erreur
  • Coût estimé

Alertes

Configurer alertes pour :

  • Agent bloqué (> timeout)
  • Usage excessif de tokens
  • Taux d'erreur élevé
  • Coûts dépassant budget

Exemples pratiques

1. Traduction parallèle

# Main agent spawne 12 subagents (1 par page)
openclaw agent "Translate these 12 pages in parallel"

2. Code review automatisé

# Agent spécialisé code
openclaw agent --profile code-reviewer "Review PR #42"

3. Support client 24/7

# config.yaml
channels:
  telegram:
    agent: "support-bot"
    autoReply: true

4. Pipeline CI/CD

Git push → Agent A (tests) → Agent B (build) → Agent C (deploy)

Ressources

Développement

Créer un agent personnalisé

Voir Development Guide pour créer vos propres agents.

Tests

# Tester orchestration
npm run test:multi-agent

# Benchmark
npm run bench:agents

---

Les agents OpenClaw permettent de construire des workflows complexes, automatisés et intelligents. Commencez simple (1 agent), puis évoluez vers des architectures multi-agents selon vos besoins.