Skip to content

codexGW/openclaw-collab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openclaw-collab

Supervised agent-to-agent collaboration plugin for OpenClaw.

Two agents take turns responding in a Discord thread while a human watches, interjects, and controls the session. The gateway orchestrates everything -- no agent edits the other's output.

Features

  • Gateway-managed turns -- neither agent can modify the other's response
  • Discord thread isolation -- each collaboration runs in its own thread
  • Webhook posting -- each agent posts with its own display name via webhook
  • Token budgets -- predictive total-budget guardrails with pre-flight checks before each turn (soft per-turn output target, tracked but not enforced by API)
  • Human interjection -- type in the thread and your message gets included in the next agent's context
  • Automatic cleanup -- sessions and webhooks cleaned up on completion or failure

How it works

Human: "Review this code for security issues"
         |
    [Gateway orchestrates]
         |
    Turn 1: Agent A responds --> posted to thread as "Agent A"
    Turn 2: Agent B responds --> posted to thread as "Agent B"
    Turn 3: Agent A responds --> posted to thread as "Agent A"
    ...
    Budget hit / max turns / human stops --> summary posted

The gateway creates a Discord thread, spawns one-shot agent sessions for each turn, posts responses via webhook, and enforces token budgets. Agents never interact directly.

Install

# Clone to OpenClaw extensions
git clone https://github.com/codexGW/openclaw-collab.git ~/.openclaw/extensions/collab

# Add to your OpenClaw config (~/.openclaw/openclaw.json)

Add the plugin path and config:

{
  "plugins": {
    "allow": ["collab"],
    "load": {
      "paths": ["~/.openclaw/extensions/collab"]
    },
    "entries": {
      "collab": {
        "enabled": true,
        "config": {
          "maxTurns": 10,
          "maxTotalTokens": 50000,
          "maxOutputTokensPerTurn": 4000,
          "turnTimeoutSeconds": 120,
          "turnDelayMs": 2000
          // "discordAccountId": "mybot" — optional, omit to use default
        }
      }
    }
  },
  "tools": {
    "alsoAllow": ["collab"]
  }
}

Important: The collab tool is registered as optional. Add "collab" to tools.alsoAllow (additive policy) or tools.allow (explicit allowlist) for agents to see it.

Then restart the gateway.

Usage

From any agent session, the collab tool becomes available:

Start a collaboration between codex and claude to review /path/to/code.ts
for security issues. Use channel 1234567890.

The agent calls the collab tool, which handles everything automatically.

Configuration

Option Default Description
maxTurns 10 Maximum total turns across both agents
maxTotalTokens 50000 Hard token budget (input + output)
maxOutputTokensPerTurn 4000 Soft per-turn output target (tracked, not enforced by API)
turnTimeoutSeconds 120 Timeout per agent turn
turnDelayMs 2000 Delay between turns (rate limit safety)
discordAccountId (configured default) Discord bot account for webhook operations (omit to use your default)

Requirements

  • OpenClaw 2026.3.7+
  • Discord bot with MANAGE_WEBHOOKS and CREATE_PUBLIC_THREADS permissions
  • At least 2 configured agents (native or ACP)

Architecture

  • index.ts -- plugin entry point, registers the tool
  • src/tool.ts -- agent tool definition (proper AnyAgentTool contract)
  • src/orchestrator.ts -- turn loop, state machine, cleanup
  • src/discord.ts -- thread creation, webhook management, message polling
  • src/budget.ts -- token budget tracking with pre-flight checks
  • src/usage-registry.ts -- global usage tracking via llm_output hooks
  • src/config.ts -- typed config parsing and validation
  • src/types.ts -- shared type definitions

Status

Alpha -- built from spec, not yet tested in production. Feedback and contributions welcome.

Related

License

MIT

About

Supervised agent-to-agent collaboration plugin for OpenClaw

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors