Skip to content

Commit 0024918

Browse files
Fix Agent Teams cross-talk with session-unique team names (#171)
* fix: use session-unique team names to prevent Agent Teams cross-talk The static team name "PACT" caused message cross-talk when users ran multiple concurrent Claude Code sessions. Now generates unique names like PACT-{session_hash} using the first 8 characters of session_id from the SessionStart hook input. Includes: generate_team_name() with fallback chain (session_id → CLAUDE_SESSION_ID env var → random hex), str() coercion for type safety, 13 unit tests, updated test fixtures. Bumps to v3.0.5. * docs: align code docstrings and comments with PACT-{session_hash} convention * docs: update markdown to use {team_name} placeholder convention - INSTRUCTIONS step 2 defines the format (PACT-{session_hash}) and tells the orchestrator to substitute wherever {team_name} appears - All code templates use {team_name} as the placeholder - Format description (PACT-{session_hash}) only in INSTRUCTIONS and rePACT prose - Verify session team step retained in protocol files only * docs: add verify session team step to all command files Previously only comPACT's protocol sections had the "Verify session team exists" safety net. Now all 5 command files include it for consistent three-layer enforcement alongside INSTRUCTIONS step 2 and the session_init hook reminder.
1 parent da2ddc3 commit 0024918

18 files changed

Lines changed: 233 additions & 48 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"name": "PACT",
1313
"source": "./pact-plugin",
1414
"description": "PACT Framework - VSM-enhanced orchestration with specialist agents and viability sensing",
15-
"version": "3.0.4",
15+
"version": "3.0.5",
1616
"author": {
1717
"name": "ProfSynapse"
1818
},

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ When installed as a plugin, PACT lives in your plugin cache:
231231
│ └── cache/
232232
│ └── pact-marketplace/
233233
│ └── PACT/
234-
│ └── 3.0.4/ # Plugin version
234+
│ └── 3.0.5/ # Plugin version
235235
│ ├── agents/
236236
│ ├── commands/
237237
│ ├── skills/

pact-plugin/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PACT",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"description": "PACT Framework - Prepare, Architect, Code, Test methodology with VSM-enhanced orchestration, specialist agents, and viability sensing for systematic AI-assisted development",
55
"author": {
66
"name": "ProfSynapse",

pact-plugin/CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ See @~/.claude/protocols/pact-plugin/algedonic.md for full protocol, trigger con
6262

6363
## INSTRUCTIONS
6464
1. Read `CLAUDE.md` at session start to understand project structure and current state
65-
2. Create the session team immediately: `TeamCreate(team_name="PACT")` — this must exist before starting any work
65+
2. Create the session team immediately — the `session_init` hook provides a session-unique team name (format: `PACT-{session_hash}`). This must exist before starting any work or spawning any agents. Use this name wherever `{team_name}` appears in commands.
6666
3. Apply the PACT framework methodology with specific principles at each phase, and delegate tasks to specific specialist agents for each phase
67-
4. **NEVER** add, change, or remove code yourself. **ALWAYS** delegate coding tasks to PACT specialist agents — your teammates on the `PACT` team.
67+
4. **NEVER** add, change, or remove code yourself. **ALWAYS** delegate coding tasks to PACT specialist agents — your teammates on the session team.
6868
5. Update `CLAUDE.md` after significant changes or discoveries (Execute `/PACT:pin-memory`)
6969
6. Follow phase-specific principles and delegate tasks to phase-specific specialist agents, in order to maintain code quality and systematic development
7070

@@ -233,7 +233,7 @@ When making decisions, consider which horizon applies. Misalignment indicates mo
233233

234234
**Core Principle**: The orchestrator coordinates; specialists execute. Don't do specialist work—delegate it.
235235

236-
***NEVER add, change, or remove application code yourself*****ALWAYS** delegate coding tasks to PACT specialist agents — your teammates on the `PACT` team.
236+
***NEVER add, change, or remove application code yourself*****ALWAYS** delegate coding tasks to PACT specialist agents — your teammates on the session team.
237237

238238
| Specialist Work | Delegate To |
239239
|-----------------|-------------|
@@ -358,14 +358,14 @@ When delegating a task, these specialist agents are available to execute PACT ph
358358

359359
### Agent Teams Dispatch
360360

361-
> ⚠️ **MANDATORY**: Specialists are spawned as teammates via `Task(name=..., team_name="PACT", subagent_type=...)`. The session team (`PACT`) is created at session start per INSTRUCTIONS step 2.
361+
> ⚠️ **MANDATORY**: Specialists are spawned as teammates via `Task(name=..., team_name="{team_name}", subagent_type=...)`. The session team is created at session start per INSTRUCTIONS step 2. The `session_init` hook provides the specific team name in your session context.
362362
>
363363
> ⚠️ **NEVER** use plain `Task(subagent_type=...)` without `name` and `team_name` for specialist agents. This bypasses team coordination, task tracking, and SendMessage communication.
364364
365365
**Dispatch pattern**:
366366
1. `TaskCreate(subject, description)` — create the tracking task with full mission
367367
2. `TaskUpdate(taskId, owner="{name}")` — assign ownership
368-
3. `Task(name="{name}", team_name="PACT", subagent_type="pact-{type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")` — spawn the teammate
368+
3. `Task(name="{name}", team_name="{team_name}", subagent_type="pact-{type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")` — spawn the teammate
369369

370370
**Exception — `pact-memory-agent`**: This agent is NOT a team member. It still uses the background task model:
371371
```python

pact-plugin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PACT Framework Plugin
22

3-
> **Version**: 3.0.4
3+
> **Version**: 3.0.5
44
> **License**: MIT
55
66
VSM-enhanced orchestration framework for AI-assisted software development with Claude Code.

pact-plugin/commands/comPACT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Before invoking multiple specialists concurrently, perform this coordination che
140140
## Pre-Invocation (Required)
141141

142142
1. **Set up worktree** — If already in a worktree for this feature, reuse it. Otherwise, invoke `/PACT:worktree-setup` with the feature branch name. All subsequent work happens in the worktree.
143-
2. **Verify session team exists** — The `PACT` team should already exist from session start. If not, create it now: `TeamCreate(team_name="PACT")`.
143+
2. **Verify session team exists** — The `{team_name}` team should already exist from session start. If not, create it now: `TeamCreate(team_name="{team_name}")`.
144144
3. **S2 coordination** (if concurrent) — Check for file conflicts, assign boundaries
145145

146146
---
@@ -154,7 +154,7 @@ When the task contains multiple independent items, invoke multiple specialists t
154154
For each specialist needed:
155155
1. `TaskCreate(subject="{specialist}: {sub-task}", description="comPACT mode (concurrent): You are one of [N] specialists working concurrently.\nYou are working in a git worktree at [worktree_path].\n\nYOUR SCOPE: [specific sub-task]\nOTHER AGENTS' SCOPE: [what others handle]\n\nWork directly from this task description.\nCheck docs/plans/, docs/preparation/, docs/architecture/ briefly if they exist.\nDo not create new documentation artifacts in docs/.\nStay within your assigned scope.\n\nTesting: New unit tests for logic changes. Fix broken existing tests. Run test suite before handoff.\n\nIf you hit a blocker, STOP and SendMessage it to the lead.\n\nTask: [this agent's specific sub-task]")`
156156
2. `TaskUpdate(taskId, owner="{specialist-name}")`
157-
3. `Task(name="{specialist-name}", team_name="PACT", subagent_type="pact-{specialist-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
157+
3. `Task(name="{specialist-name}", team_name="{team_name}", subagent_type="pact-{specialist-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
158158

159159
Spawn all specialists in parallel (multiple `Task` calls in one response).
160160

@@ -171,7 +171,7 @@ Use a single specialist agent only when:
171171
**Dispatch the specialist**:
172172
1. `TaskCreate(subject="{specialist}: {task}", description="comPACT mode: Work directly from this task description.\nYou are working in a git worktree at [worktree_path].\nCheck docs/plans/, docs/preparation/, docs/architecture/ briefly if they exist.\nDo not create new documentation artifacts in docs/.\nFocus on the task at hand.\n\nTesting: New unit tests for logic changes (optional for trivial changes). Fix broken existing tests. Run test suite before handoff.\n\n> Smoke vs comprehensive tests: These are verification tests. Comprehensive coverage is TEST phase work.\n\nIf you hit a blocker, STOP and SendMessage it to the lead.\n\nTask: [user's task description]")`
173173
2. `TaskUpdate(taskId, owner="{specialist-name}")`
174-
3. `Task(name="{specialist-name}", team_name="PACT", subagent_type="pact-{specialist-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
174+
3. `Task(name="{specialist-name}", team_name="{team_name}", subagent_type="pact-{specialist-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
175175

176176
---
177177

pact-plugin/commands/orchestrate.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ b. Analyze work needed (QDCL for CODE)
3838
c. TaskCreate: agent task(s) as children of phase
3939
d. TaskUpdate: agent tasks owner = "{agent-name}"
4040
e. TaskUpdate: next phase addBlockedBy = [agent IDs]
41-
f. Spawn teammates: Task(name="{name}", team_name="PACT", subagent_type="pact-{type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")
41+
f. Spawn teammates: Task(name="{name}", team_name="{team_name}", subagent_type="pact-{type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")
4242
g. Monitor via SendMessage (HANDOFFs) and TaskList until agents complete
4343
h. TaskUpdate: phase status = "completed" (agents self-manage their task status)
4444
```
@@ -164,7 +164,7 @@ Sequential execution is the exception requiring explicit justification. When ass
164164
---
165165

166166
1. **Set up worktree**: If already in a worktree for this feature, reuse it. Otherwise, invoke `/PACT:worktree-setup` with the feature branch name. This creates both the feature branch and its worktree. All subsequent phases work in the worktree.
167-
2. **Verify session team exists**: The `PACT` team should already exist from session start. If not, create it now: `TeamCreate(team_name="PACT")`.
167+
2. **Verify session team exists**: The `{team_name}` team should already exist from session start. If not, create it now: `TeamCreate(team_name="{team_name}")`.
168168
3. **Check for plan** in `docs/plans/` matching this task
169169

170170
### Plan Status Handling
@@ -254,7 +254,7 @@ When a phase is skipped but a coder encounters a decision that would have been h
254254
1. `TaskCreate(subject="preparer: research {feature}", description="CONTEXT: ...\nMISSION: ...\nINSTRUCTIONS: ...\nGUIDELINES: ...")`
255255
- Include task description, plan sections (if any), and "Reference the approved plan at `docs/plans/{slug}-plan.md` for full context."
256256
2. `TaskUpdate(taskId, owner="preparer")`
257-
3. `Task(name="preparer", team_name="PACT", subagent_type="pact-preparer", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
257+
3. `Task(name="preparer", team_name="{team_name}", subagent_type="pact-preparer", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
258258

259259
Completed-phase teammates remain as consultants. Do not shutdown during this workflow.
260260

@@ -324,7 +324,7 @@ When detection fires (score >= threshold), follow the evaluation response protoc
324324
- Do not read phase output files yourself or paste their content into the task description.
325325
- If PREPARE was skipped: pass the plan's Preparation Phase section instead.
326326
2. `TaskUpdate(taskId, owner="architect")`
327-
3. `Task(name="architect", team_name="PACT", subagent_type="pact-architect", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
327+
3. `Task(name="architect", team_name="{team_name}", subagent_type="pact-architect", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
328328

329329
Completed-phase teammates remain as consultants. Do not shutdown during this workflow.
330330

@@ -412,7 +412,7 @@ For each coder needed:
412412
- If PREPARE/ARCHITECT were skipped, include: "PREPARE and/or ARCHITECT were skipped based on existing context. Minor decisions (naming, local structure) are yours to make. For moderate decisions (interface shape, error patterns), decide and implement but flag the decision with your rationale in the handoff so it can be validated. Major decisions affecting other components are blockers—don't implement, escalate."
413413
- Include: "Smoke Testing: Run the test suite before completing. If your changes break existing tests, fix them. Your tests are verification tests—enough to confirm your implementation works. Comprehensive coverage (edge cases, integration, E2E, adversarial) is TEST phase work."
414414
2. `TaskUpdate(taskId, owner="{coder-name}")`
415-
3. `Task(name="{coder-name}", team_name="PACT", subagent_type="pact-{coder-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
415+
3. `Task(name="{coder-name}", team_name="{team_name}", subagent_type="pact-{coder-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
416416

417417
Spawn multiple coders in parallel (multiple `Task` calls in one response). Include worktree path and S2 scope boundaries in each task description.
418418

@@ -475,7 +475,7 @@ Execute the [CONSOLIDATE Phase protocol](../protocols/pact-scope-phases.md#conso
475475
- Include task description, CODE phase handoff summaries (from SendMessage, not files), plan sections (if any), plan reference.
476476
- Include: "You own ALL substantive testing: unit tests, integration, E2E, edge cases."
477477
2. `TaskUpdate(taskId, owner="test-engineer")`
478-
3. `Task(name="test-engineer", team_name="PACT", subagent_type="pact-test-engineer", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
478+
3. `Task(name="test-engineer", team_name="{team_name}", subagent_type="pact-test-engineer", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
479479

480480
**Before completing**:
481481
- [ ] All tests passing

pact-plugin/commands/peer-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Review task: in_progress (persists until merge-ready)
8585

8686
**PR Review Workflow**
8787

88-
The `PACT` team should already exist from session start. If not, create it now: `TeamCreate(team_name="PACT")`.
88+
**Verify session team exists**: The `{team_name}` team should already exist from session start. If not, create it now: `TeamCreate(team_name="{team_name}")`.
8989

9090
Pull request reviews should mirror real-world team practices where multiple reviewers sign off before merging. Dispatch **at least 3 reviewers in parallel** to provide comprehensive review coverage:
9191

@@ -105,7 +105,7 @@ Select the domain coder based on PR focus:
105105
For each reviewer:
106106
1. `TaskCreate(subject="{reviewer-type}: review {feature}", description="Review this PR. Focus: [domain-specific review criteria]...")`
107107
2. `TaskUpdate(taskId, owner="{reviewer-name}")`
108-
3. `Task(name="{reviewer-name}", team_name="PACT", subagent_type="pact-{reviewer-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
108+
3. `Task(name="{reviewer-name}", team_name="{team_name}", subagent_type="pact-{reviewer-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
109109

110110
Spawn all reviewers in parallel (multiple `Task` calls in one response).
111111

pact-plugin/commands/plan-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Skip specialists clearly not relevant (e.g., skip database engineer for pure UI
9797

9898
### Phase 1: Parallel Specialist Consultation
9999

100-
The `PACT` team should already exist from session start. If not, create it now: `TeamCreate(team_name="PACT")`.
100+
**Verify session team exists**: The `{team_name}` team should already exist from session start. If not, create it now: `TeamCreate(team_name="{team_name}")`.
101101

102102
Dispatch relevant specialists **in parallel**, each in **planning-only mode**.
103103

@@ -177,7 +177,7 @@ If a specialist fails entirely (timeout, error):
177177
**Dispatch each consultant**:
178178
1. `TaskCreate(subject="{specialist}: plan consultation for {feature}", description="PLANNING CONSULTATION ONLY — No implementation.\n\nTask: {task description}\n\n[full template content from above]")`
179179
2. `TaskUpdate(taskId, owner="{specialist-name}")`
180-
3. `Task(name="{specialist-name}", team_name="PACT", subagent_type="pact-{specialist-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
180+
3. `Task(name="{specialist-name}", team_name="{team_name}", subagent_type="pact-{specialist-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
181181

182182
Spawn all consultants in parallel.
183183

pact-plugin/commands/rePACT.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Run a recursive PACT cycle for this sub-task: $ARGUMENTS
66

77
This command initiates a **nested P→A→C→T cycle** for a sub-task that is too complex for simple delegation but should remain part of the current feature work.
88

9-
**Team behavior**: rePACT spawns sub-scope teammates into the existing session team (`PACT`). No new team is created. Use scope-prefixed names (e.g., `backend-coder-auth-scope`) to distinguish sub-scope teammates from parent-scope teammates.
9+
**Team behavior**: rePACT spawns sub-scope teammates into the existing session team (`PACT-{session_hash}`). No new team is created. Use scope-prefixed names (e.g., `backend-coder-auth-scope`) to distinguish sub-scope teammates from parent-scope teammates.
1010

1111
---
1212

@@ -205,10 +205,12 @@ Design the sub-component:
205205

206206
Implement the sub-component:
207207

208+
**Verify session team exists**: The `{team_name}` team should already exist from session start. If not, create it now: `TeamCreate(team_name="{team_name}")`.
209+
208210
For each specialist needed:
209211
1. `TaskCreate(subject="{scope-prefixed-name}: implement {sub-task}", description="[full CONTEXT/MISSION/INSTRUCTIONS/GUIDELINES]")`
210212
2. `TaskUpdate(taskId, owner="{scope-prefixed-name}")`
211-
3. `Task(name="{scope-prefixed-name}", team_name="PACT", subagent_type="pact-{specialist-type}", prompt="You are joining team PACT. Check TaskList for tasks assigned to you.")`
213+
3. `Task(name="{scope-prefixed-name}", team_name="{team_name}", subagent_type="pact-{specialist-type}", prompt="You are joining team {team_name}. Check TaskList for tasks assigned to you.")`
212214

213215
For multi-domain: spawn multiple specialists in parallel.
214216
Apply S2 coordination if parallel work.

0 commit comments

Comments
 (0)