3.7 KiB
3.7 KiB
Agent Team Collaboration Framework Implementation
Overview
Implemented a true agent team collaboration framework with shared blackboard, parallel execution, and automatic challenge rounds.
Changes Made
1. internal/agent/agent.go
- Added
CanChallenge boolfield toConfigstruct - Allows agents to participate in the challenge round
2. internal/room/room.go
-
Added imports:
syncfor concurrent operations -
New types:
BoardEntry: Represents a single entry on the shared boardSharedBoard: Thread-safe shared blackboard with mutex protectionAdd(author, content, typ): Add entries to the boardToContext(): Convert board to XML context for agents
-
New methods:
-
runMembersParallel(): Execute all assignments concurrently using goroutines and WaitGroup- Each member sees the current board snapshot
- Results are added to the board as "draft" entries
- Emits streaming events for real-time UI updates
-
runChallengeRound(): Automatic challenge phase after draft completion- Only agents with
CanChallenge=trueparticipate - Each challenger sees the full board
- Outputs
CHALLENGE:<concern>orAGREE - Challenge entries are added to the board
- Only agents with
-
-
Refactored
HandleUserMessage():- Replaced sequential member execution with
runMembersParallel() - Added automatic
runChallengeRound()after parallel execution - Master receives complete board (drafts + challenges) for final review
- Board context is injected into master's feedback message
- Replaced sequential member execution with
-
Updated
Eventstruct:- Role field now supports "challenge" in addition to "master" and "member"
3. Agent Configuration Files
agents/legal-team/合规专员/AGENT.md
- Added
can_challenge: true
agents/legal-team/合同律师/AGENT.md
- Added
can_challenge: true
4. Agent System Prompts (SOUL.md)
agents/legal-team/合规专员/SOUL.md
- Added "质疑机制" (Challenge Mechanism) section
- Instructions to actively challenge when seeing
<team_board> - Format:
CHALLENGE:<specific compliance risk or suggestion>
agents/legal-team/合同律师/SOUL.md
- Added "质疑与修订机制" (Challenge & Revision Mechanism) section
- Instructions to review other members' opinions
- Ability to challenge compliance officer's suggestions if conflicts exist
- Preparation to revise work when challenged
agents/legal-team/法律总监/SOUL.md
- Added "处理 CHALLENGE 的决策指令" (Decision Instructions for Handling CHALLENGE)
- Evaluate challenge validity
- Decide whether to request revisions or reassign tasks
- Document how challenges were addressed in final recommendations
New Workflow
User Question
↓
Master Plans → ASSIGN:member1:task1 + ASSIGN:member2:task2
↓
[Parallel] Members execute simultaneously (each sees empty board initially)
↓
[Auto] Challenge Round: Members with CanChallenge=true review board
↓
Master sees complete board (drafts + challenges) → DONE or re-ASSIGN
Key Features
- Parallel Execution: Members work concurrently, not sequentially
- Shared Blackboard: All members can see each other's work via
<team_board> - Automatic Challenge Round: Triggered after parallel execution completes
- Thread-Safe: Uses sync.RWMutex for concurrent board access
- Streaming Events: Real-time UI updates with "challenge" role events
- Master Integration: Board context fed back to master for informed decisions
Verification
- ✅ Code compiles:
go build ./... - ✅ All imports added correctly
- ✅ Thread-safety ensured with sync primitives
- ✅ Event streaming maintained for UI
- ✅ Backward compatible with existing master/member roles