Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
587ef4d
merge: incorporate multi-agent routing (PR #131)
Leeaandrob Feb 18, 2026
f5c2269
feat: add multi-agent collaboration framework (#294)
Leeaandrob Feb 18, 2026
c9a5769
Merge remote-tracking branch 'upstream/main' into feat/multi-agent-fr…
Leeaandrob Feb 18, 2026
38ff3b8
docs: add C4 architecture diagrams for multi-agent framework
Leeaandrob Feb 18, 2026
ef4ee76
refactor: fix 62 golangci-lint issues across multiagent and routing p…
Leeaandrob Feb 18, 2026
a3ad40c
docs: add PRP and update architecture with hardening roadmap
Leeaandrob Feb 18, 2026
e121c7c
feat: add Capabilities field to AgentInfo for capability-based routing
edouard-claude Feb 18, 2026
d8255f1
feat: enable capability-based routing in HandoffTool
edouard-claude Feb 18, 2026
c5145f1
Merge pull request #1 from edouard-claude/feat/multi-agent-enhancements
Leeaandrob Feb 18, 2026
4def7b4
fix: resolve blackboard split-brain in multi-agent tools
Leeaandrob Feb 18, 2026
eb707ff
feat: add recursion guard with depth limit and cycle detection
Leeaandrob Feb 18, 2026
f73c153
feat: enforce handoff allowlist with default-open policy
Leeaandrob Feb 18, 2026
42d73bd
feat: add ToolHook interface for before/after execution interception
Leeaandrob Feb 18, 2026
284f17e
test: add tests for board wiring, recursion guards, allowlist, and hooks
Leeaandrob Feb 18, 2026
660a70c
test: add edge-case coverage for phase 1 hardening
Leeaandrob Feb 18, 2026
148623f
feat: add tool group definitions for policy-based filtering
Leeaandrob Feb 18, 2026
f3a838f
feat: add ToolPolicyConfig for per-agent tool filtering
Leeaandrob Feb 18, 2026
0b251e7
feat: add policy engine with registry Clone and Remove
Leeaandrob Feb 18, 2026
5837d36
feat: wire tool policy pipeline into agent registration and handoff
Leeaandrob Feb 18, 2026
26cd169
test: add comprehensive tests for tool policy pipeline
Leeaandrob Feb 18, 2026
09061d8
fix: align struct fields and method signatures for goimports
Leeaandrob Feb 18, 2026
751c7f4
fix: add rate-limit retry with exponential backoff
Leeaandrob Feb 18, 2026
239dcea
feat: add loop detector with hash-based repeat and ping-pong detection
Leeaandrob Feb 18, 2026
076f526
feat: wire loop detector into agent tool execution pipeline
Leeaandrob Feb 18, 2026
276523b
test: add comprehensive loop detector tests
Leeaandrob Feb 18, 2026
cdc8c14
feat: add RunRegistry with cascade stop for agent run cancellation
Leeaandrob Feb 18, 2026
03b9593
feat: wire cascade stop into handoff pipeline
Leeaandrob Feb 18, 2026
94675e0
test: add comprehensive cascade stop tests
Leeaandrob Feb 18, 2026
d832807
feat: add 3-tier context overflow recovery with tool result truncation
Leeaandrob Feb 19, 2026
372dfa0
test: add tool result truncation tests
Leeaandrob Feb 19, 2026
b00a8a5
feat: add auth profile rotation with per-key cooldown
Leeaandrob Feb 19, 2026
aff3076
feat: wire auth rotation into config and provider factory
Leeaandrob Feb 19, 2026
b80b2b1
test: add auth rotation and rotating provider tests
Leeaandrob Feb 19, 2026
0b7d3b9
feat: add async spawn manager with announcer protocol
Leeaandrob Feb 19, 2026
b3d5dc9
feat: add session-scoped process isolation
Leeaandrob Feb 19, 2026
342182a
feat: add idempotency cache with deterministic keys
Leeaandrob Feb 19, 2026
4a37fba
feat: wire async spawn and announcer into agent loop
Leeaandrob Feb 19, 2026
290796e
test: add async spawn, announcer, dedup, and process scope tests
Leeaandrob Feb 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# PicoClaw Multi-Agent Architecture

This directory contains C4 model diagrams (rendered with Mermaid) documenting the multi-agent collaboration framework for PicoClaw.

## Reference Implementation

**OpenClaw (moltbot)** β€” the state-of-the-art personal AI gateway whose founder was hired by OpenAI. picoclaw ports and improves upon OpenClaw's validated patterns in a lightweight Go single-binary.

- Reference code: `/home/leeaandrob/Projects/Personal/llm/auto-agents/moltbot`
- See [PRP](../prp/multi-agent-hardening.md) for detailed implementation plan

## Documents

| Document | Scope | Description |
|----------|-------|-------------|
| [C1 - System Context](./c1-system-context.md) | Highest level | PicoClaw in its ecosystem: users, channels, LLM providers |
| [C2 - Container](./c2-container.md) | Runtime containers | Gateway, Agent Loop, Provider Layer, Channels |
| [C3 - Component](./c3-component-multi-agent.md) | Multi-agent internals | Current + planned components across 4 hardening phases |
| [C4 - Code](./c4-code-detail.md) | Key structs/interfaces | Go interfaces, data flow, tool execution |
| [Sequence Diagrams](./sequences.md) | Runtime flows | Handoff, Blackboard sync, Fallback chain |
| [Roadmap](./roadmap.md) | Phased plan | 4-phase hardening based on OpenClaw gap analysis |

## Related

- **PRP**: [Multi-Agent Hardening](../prp/multi-agent-hardening.md) β€” Full implementation plan with acceptance criteria
- **Issue**: [#294 - Base Multi-agent Collaboration Framework](https://github.com/sipeed/picoclaw/issues/294)
- **Issue**: [#283 - Refactor Provider Architecture](https://github.com/sipeed/picoclaw/issues/283)
- **Discussion**: [#122 - Provider Architecture Proposal](https://github.com/sipeed/picoclaw/discussions/122)

## Status

| Phase | Status | PR |
|-------|--------|----|
| Provider Protocol Refactor | Merged | [#213](https://github.com/sipeed/picoclaw/pull/213) |
| Model Fallback + Routing | Merged | [#131](https://github.com/sipeed/picoclaw/pull/131) |
| Blackboard + Handoff + Discovery | WIP | [#423](https://github.com/sipeed/picoclaw/pull/423) |
| Phase 1: Foundation Fix | Planned | PR #423 |
| Phase 2: Tool Policy | Planned | PR #423 |
| Phase 3: Resilience | Planned | TBD |
| Phase 4: Async Multi-Agent | Planned | TBD |
| SOUL.md Bootstrap | In Progress (other dev) | TBD |

## picoclaw Advantages Over OpenClaw

| Area | picoclaw | OpenClaw |
|------|----------|----------|
| Shared agent state | Blackboard (real-time) | None (announce-only) |
| Runtime | Go single binary | Node.js |
| Memory footprint | ~10x smaller | Node.js overhead |
| Deployment | Copy binary and run | npm install + config |
| Concurrency | goroutines (native) | async/await |
| Type safety | Compile-time | Runtime |
59 changes: 59 additions & 0 deletions docs/architecture/c1-system-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# C1 - System Context Diagram

PicoClaw as a multi-agent platform within its ecosystem.

```mermaid
C4Context
title System Context - PicoClaw Multi-Agent Platform

Person(user, "User", "Interacts via messaging channels or CLI")
Person(dev, "Developer", "Configures agents, skills, and providers")

System(picoclaw, "PicoClaw", "Multi-agent AI platform that routes user messages to specialized agents backed by multiple LLM providers")

System_Ext(discord, "Discord", "Chat platform")
System_Ext(telegram, "Telegram", "Chat platform")
System_Ext(slack, "Slack", "Workspace messaging")
System_Ext(whatsapp, "WhatsApp", "Messaging")
System_Ext(cli, "CLI", "Direct terminal access")

System_Ext(openai, "OpenAI API", "GPT models, Codex")
System_Ext(anthropic, "Anthropic API", "Claude models")
System_Ext(gemini, "Google Gemini", "Gemini models")
System_Ext(openrouter, "OpenRouter", "Multi-model gateway")
System_Ext(groq, "Groq", "Fast inference")
System_Ext(ollama, "Ollama", "Local LLM")
System_Ext(claude_cli, "Claude Code CLI", "Subprocess provider")
System_Ext(codex_cli, "Codex CLI", "Subprocess provider")

Rel(user, discord, "Sends messages")
Rel(user, telegram, "Sends messages")
Rel(user, slack, "Sends messages")
Rel(user, whatsapp, "Sends messages")
Rel(user, cli, "Direct input")
Rel(dev, picoclaw, "Configures via config.json")

Rel(discord, picoclaw, "Webhook/Bot events")
Rel(telegram, picoclaw, "Bot API")
Rel(slack, picoclaw, "Events API")
Rel(whatsapp, picoclaw, "Webhook")
Rel(cli, picoclaw, "Stdin/Stdout")

Rel(picoclaw, openai, "HTTPS/REST")
Rel(picoclaw, anthropic, "HTTPS/REST")
Rel(picoclaw, gemini, "HTTPS/REST")
Rel(picoclaw, openrouter, "HTTPS/REST")
Rel(picoclaw, groq, "HTTPS/REST")
Rel(picoclaw, ollama, "HTTP localhost")
Rel(picoclaw, claude_cli, "Subprocess stdio")
Rel(picoclaw, codex_cli, "Subprocess stdio")
```

## Key interactions

| Boundary | Protocol | Direction |
|----------|----------|-----------|
| User -> Channels | Platform-native (Discord bot, Telegram bot, etc.) | Inbound |
| Channels -> PicoClaw | Go channel bus (`pkg/bus`) | Internal |
| PicoClaw -> LLM Providers | HTTPS REST / Subprocess stdio | Outbound |
| Developer -> PicoClaw | `~/.picoclaw/config.json` + workspace files | Config |
58 changes: 58 additions & 0 deletions docs/architecture/c2-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# C2 - Container Diagram

Runtime containers inside PicoClaw.

```mermaid
C4Container
title Container Diagram - PicoClaw Runtime

Person(user, "User")

System_Boundary(picoclaw, "PicoClaw Process") {
Container(gateway, "Gateway", "Go HTTP server", "Exposes health/ready endpoints, manages lifecycle")
Container(channel_mgr, "Channel Manager", "pkg/channels", "Manages Discord, Telegram, Slack, WhatsApp, CLI connections")
Container(msg_bus, "Message Bus", "pkg/bus", "Pub/sub event bus routing messages between channels and agents")
Container(agent_loop, "Agent Loop", "pkg/agent", "Core orchestrator: routes messages to agents, manages tool loops, sessions")
Container(registry, "Agent Registry", "pkg/agent", "Stores AgentInstance configs, resolves agent by ID or route")
Container(router, "Route Resolver", "pkg/routing", "Matches incoming messages to agents based on channel/chat/peer bindings")
Container(multiagent, "Multi-Agent Framework", "pkg/multiagent", "Blackboard shared context, Handoff mechanism, Agent discovery tools")
Container(tools, "Tool Registry", "pkg/tools", "Shell, file, web, session, message, spawn, exec tools")
Container(providers, "Provider Layer", "pkg/providers", "LLM provider abstraction: HTTP, CLI, OAuth, Fallback chain")
Container(session, "Session Store", "pkg/session", "Per-agent session persistence with conversation history")
Container(skills, "Skills Engine", "pkg/skills", "Loads SKILL.md files, provides skill tools to agents")
Container(config, "Config", "pkg/config", "Loads config.json, agent definitions, model_list")
}

System_Ext(llm, "LLM Providers", "OpenAI, Anthropic, Gemini, Groq, Ollama, Claude CLI, Codex CLI")
System_Ext(channels_ext, "Messaging Platforms", "Discord, Telegram, Slack, WhatsApp")

Rel(user, channels_ext, "Sends message")
Rel(channels_ext, channel_mgr, "Delivers event")
Rel(channel_mgr, msg_bus, "Publishes message")
Rel(msg_bus, agent_loop, "Delivers to agent")
Rel(agent_loop, router, "Resolves target agent")
Rel(agent_loop, registry, "Gets AgentInstance")
Rel(agent_loop, multiagent, "Blackboard sync, Handoff")
Rel(agent_loop, tools, "Executes tool calls")
Rel(agent_loop, session, "Load/save history")
Rel(agent_loop, skills, "Resolves skill tools")
Rel(agent_loop, providers, "LLM Chat()")
Rel(providers, llm, "API calls")
Rel(gateway, agent_loop, "Lifecycle management")
Rel(config, agent_loop, "Agent definitions")
Rel(config, providers, "Provider config")
Rel(config, registry, "AgentConfig list")
```

## Container responsibilities

| Container | Package | Key types |
|-----------|---------|-----------|
| Agent Loop | `pkg/agent` | `AgentLoop`, `RunToolLoop()` |
| Agent Registry | `pkg/agent` | `AgentRegistry`, `AgentInstance` |
| Route Resolver | `pkg/routing` | `RouteResolver`, `SessionKeyBuilder` |
| Multi-Agent | `pkg/multiagent` | `Blackboard`, `HandoffTool`, `ListAgentsTool` |
| Provider Layer | `pkg/providers` | `LLMProvider`, `FallbackChain`, `HTTPProvider` |
| Tool Registry | `pkg/tools` | `Tool`, `ContextualTool`, `AsyncTool` |
| Session Store | `pkg/session` | `SessionStore`, conversation history |
| Config | `pkg/config` | `Config`, `AgentConfig`, `ModelConfig` |
Loading
Loading