← Back to Plugins
Tools

Agent Interaction Logger

nishantapatil3 By nishantapatil3 👁 39 views ▲ 0 votes

OpenClaw plugin for monitoring agent lifecycle events, LLM I/O, and inter-agent communication

GitHub

README

# Agent Interaction Logger (AIL)

**Goal**: Log and monitor real-time agent communications in OpenClaw.

## ๐ŸŽฏ Quick Answer

**Question**: Is skills better or plugins better for this?  
**Answer**: **PLUGIN** (see [COMPARISON.md](COMPARISON.md) for full analysis)

## ๐Ÿ“š Documentation Index

### ๐Ÿš€ Getting Started
- **[QUICK-START.md](docs/QUICK-START.md)** โญ **START HERE** - Step-by-step setup and testing guide
- **[SUMMARY.txt](SUMMARY.txt)** - TL;DR of everything

### ๐Ÿ“– Understanding the Options
- **[COMPARISON.md](docs/COMPARISON.md)** - Plugins vs Skills vs Internal Hooks comparison table
- **[ARCHITECTURE-DIAGRAM.md](docs/ARCHITECTURE-DIAGRAM.md)** - Visual diagrams of how it all works
- **[ALTERNATIVE-APPROACHES.md](docs/ALTERNATIVE-APPROACHES.md)** - Code examples for each approach

### ๐Ÿงช Testing
- **[test-scenario.md](docs/test-scenario.md)** - Test scenarios to validate functionality

## ๐Ÿ“ Implementation Files

### Main Plugin (USE THIS)
- **[plugin.ts](plugin.ts)** - Complete implementation with all 9 hooks
- **[openclaw.plugin.json](openclaw.plugin.json)** - Plugin manifest
- **[package.json](package.json)** - Package metadata

## โšก Quick Start (3 Steps)

```bash
# 1. Register plugin in config
echo '{
  "plugins": { "dirs": ["/home/ubuntu/openclaw/experiment-mitm-agent"] }
}' >> ~/.openclaw/config.json

# 2. Start gateway
openclaw gateway run

# 3. Test (in another terminal)
openclaw agent --message "Create a team with 2 agents to research OpenClaw"
```

**Expected**: You'll see `[AIL] Plugin loaded!` and real-time event logs!

## โœ… What This Plugin Does

- โœ… **Monitors** all agent lifecycle events (spawn โ†’ execute โ†’ end)
- โœ… **Monitors** LLM input/output in real-time
- โœ… **Injects** messages into running agents via API
- โœ… **Intercepts** and can replace agent replies before they're sent
- โœ… **Reads** full conversation history from any agent
- โœ… **Tracks** active agents and their status

## ๐Ÿ”ง Current Status

Feature | Status
--------|--------
Basic monitoring | โœ… Implemented
Message injection | โš ๏ธ Code ready (commented out)
Reply interception | โš ๏ธ Code ready (commented out)
Cross-agent context sharing | ๐Ÿ“ See QUICK-START.md Advanced section

## ๐Ÿ—๏ธ Architecture

```
Your Plugin (all hooks)
    โ†“ โ†‘
OpenClaw Gateway
    โ†“ โ†‘
Agent A โ†โ†’ Agent B โ†โ†’ Agent C
```

The plugin sits between the gateway and agents, seeing and controlling all communication.

## ๐Ÿ“Š Available Hooks (All 28)

The plugin uses 9 key hooks:

1. `subagent_spawning` - Detect agent spawn
2. `subagent_spawned` - Agent ready (has runId)
3. `llm_input` - See prompts going to LLM
4. `llm_output` - See LLM responses
5. `before_agent_reply` - Intercept replies (can short-circuit!)
6. `message_sending` - Before external send
7. `message_sent` - After send confirmed
8. `message_received` - Inbound messages
9. `subagent_ended` - Agent finished (read full history)

## ๐Ÿ†˜ Help

- **Setup issues?** See [QUICK-START.md](docs/QUICK-START.md) debugging section
- **Understanding approaches?** See [COMPARISON.md](docs/COMPARISON.md)
- **Need examples?** See [ALTERNATIVE-APPROACHES.md](docs/ALTERNATIVE-APPROACHES.md)
- **Architecture questions?** See [ARCHITECTURE-DIAGRAM.md](docs/ARCHITECTURE-DIAGRAM.md)

## ๐ŸŽ“ Key Takeaways

1. **Plugins** = Full logging capability (28 hooks, runtime API)
2. **Skills** = User-invoked only (no auto-intercept)
3. **Internal Hooks** = Limited events (12 vs 28, missing subagent hooks)

**For logging agent interactions: Use the Plugin approach** (already implemented in `plugin.ts`)
tools

Comments

Sign in to leave a comment

Loading comments...