Skip to content
Back to skills

Multi Agent System

ASecurity

Design and orchestrate multi-agent AI systems with knowledge harvesting, agent collaboration, and learning loops. Use when working on PSI Engine or similar autonomous agent projects.

  • 33 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 10, 2026
ai-agentspython

Works with

  • terminal
  • cli

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add lovedragonball/power-ranger-toolkit --skill multi-agent-system --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Multi Agent System?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Multi Agent System
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/lovedragonball-multi-agent-system/badge)](https://www.skillsdirectory.com/skills/lovedragonball-multi-agent-system)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: multi-agent-system
description: Design and orchestrate multi-agent AI systems with knowledge harvesting, agent collaboration, and learning loops. Use when working on PSI Engine or similar autonomous agent projects.
---

# πŸ€– Multi-Agent System Skill

## Use Cases
- Agent spawning & lifecycle management
- Knowledge harvesting from completed tasks
- Agent-to-agent communication
- Learning loop implementation

---

## Agent Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Orchestrator               β”‚
β”‚  (Assign tasks, monitor, coordinate)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό            β–Ό            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Agent 1β”‚  β”‚ Agent 2β”‚  β”‚ Agent 3β”‚
β”‚ (Task) β”‚  β”‚ (Task) β”‚  β”‚ (Task) β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
     β”‚           β”‚           β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Knowledge Base β”‚
        β”‚   (ChromaDB)   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Agent Lifecycle

### 1. Spawn Agent
```python
def spawn_agent(agent_id: str, task: str):
    # Create PTY for agent terminal
    master, slave = pty.openpty()
    
    # Spawn process
    process = subprocess.Popen(
        ['claude', '--task', task],
        stdin=slave,
        stdout=slave,
        stderr=slave,
        start_new_session=True
    )
    
    return {
        'id': agent_id,
        'process': process,
        'master_fd': master,
        'status': 'running'
    }
```

### 2. Monitor Agent
```python
def monitor_agent(agent):
    # Read output non-blocking
    ready, _, _ = select.select([agent['master_fd']], [], [], 0.1)
    if ready:
        output = os.read(agent['master_fd'], 4096).decode()
        return output
    return None
```

### 3. Harvest Knowledge
```python
def harvest_knowledge(completed_task):
    # Extract learnings
    learnings = {
        'task': completed_task['description'],
        'solution': completed_task['output'],
        'patterns': extract_patterns(completed_task['output']),
        'timestamp': datetime.now().isoformat()
    }
    
    # Store in vector DB
    collection.add(
        documents=[learnings['solution']],
        metadatas=[learnings],
        ids=[f"learning_{uuid.uuid4()}"]
    )
```

---

## ChromaDB Integration

### Setup
```python
import chromadb

client = chromadb.Client()
collection = client.get_or_create_collection("knowledge_base")
```

### Store
```python
collection.add(
    documents=["Solution text here"],
    metadatas=[{"source": "agent_1", "task": "debug"}],
    ids=["unique_id"]
)
```

### Query (RAG)
```python
results = collection.query(
    query_texts=["How to fix null pointer?"],
    n_results=5
)
```

---

## Learning Loop

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Agent runs   β”‚
β”‚    task      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Task result  β”‚
β”‚  extracted   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Knowledge   β”‚  ← Store patterns, solutions
β”‚  harvested   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Next agent  β”‚  ← Query relevant context
β”‚ uses context β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Decision Tree

```
Multi-agent task?
β”œβ”€β”€ Need new agent? β†’ spawn_agent()
β”œβ”€β”€ Agent stuck? β†’ Check PTY buffer, restart if needed
β”œβ”€β”€ Task complete? β†’ Harvest knowledge β†’ ChromaDB
β”œβ”€β”€ Similar task? β†’ Query ChromaDB for context
└── Coordination? β†’ Use message queue/shared state
```

---

## Common Issues

| ปัญหา | ΰΈͺΰΈ²ΰΉ€ΰΈ«ΰΈ•ΰΈΈ | แก้ไข |
|-------|--------|-------|
| Agent 3 malfunction | PTY buffer full | Increase buffer / flush regularly |
| Terminal blank | Non-blocking read timing | Use select() with timeout |
| Busy false positive | Status not reset | Reset status after task complete |
| Knowledge not found | Wrong embedding | Tune ChromaDB collection settings |

---

## PSI Engine Specific

1. **PTY Manager**: Always close unused file descriptors
2. **Agent Status**: Use enum (IDLE, RUNNING, COMPLETE, ERROR)
3. **Harvest timing**: Only harvest after verified completion
4. **Context injection**: Limit to 5 most relevant results

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…