You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: pact-plugin/CLAUDE.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,9 +62,9 @@ See @~/.claude/protocols/pact-plugin/algedonic.md for full protocol, trigger con
62
62
63
63
## INSTRUCTIONS
64
64
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.
66
66
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.
68
68
5. Update `CLAUDE.md` after significant changes or discoveries (Execute `/PACT:pin-memory`)
69
69
6. Follow phase-specific principles and delegate tasks to phase-specific specialist agents, in order to maintain code quality and systematic development
70
70
@@ -233,7 +233,7 @@ When making decisions, consider which horizon applies. Misalignment indicates mo
233
233
234
234
**Core Principle**: The orchestrator coordinates; specialists execute. Don't do specialist work—delegate it.
235
235
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.
237
237
238
238
| Specialist Work | Delegate To |
239
239
|-----------------|-------------|
@@ -358,14 +358,14 @@ When delegating a task, these specialist agents are available to execute PACT ph
358
358
359
359
### Agent Teams Dispatch
360
360
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.
362
362
>
363
363
> ⚠️ **NEVER** use plain `Task(subagent_type=...)` without `name` and `team_name` for specialist agents. This bypasses team coordination, task tracking, and SendMessage communication.
364
364
365
365
**Dispatch pattern**:
366
366
1.`TaskCreate(subject, description)` — create the tracking task with full mission
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
369
369
370
370
**Exception — `pact-memory-agent`**: This agent is NOT a team member. It still uses the background task model:
Copy file name to clipboardExpand all lines: pact-plugin/commands/comPACT.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ Before invoking multiple specialists concurrently, perform this coordination che
140
140
## Pre-Invocation (Required)
141
141
142
142
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}")`.
@@ -154,7 +154,7 @@ When the task contains multiple independent items, invoke multiple specialists t
154
154
For each specialist needed:
155
155
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]")`
156
156
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.")`
158
158
159
159
Spawn all specialists in parallel (multiple `Task` calls in one response).
160
160
@@ -171,7 +171,7 @@ Use a single specialist agent only when:
171
171
**Dispatch the specialist**:
172
172
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]")`
173
173
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.")`
Copy file name to clipboardExpand all lines: pact-plugin/commands/orchestrate.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ b. Analyze work needed (QDCL for CODE)
38
38
c. TaskCreate: agent task(s) as children of phase
39
39
d. TaskUpdate: agent tasks owner = "{agent-name}"
40
40
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.")
42
42
g. Monitor via SendMessage (HANDOFFs) and TaskList until agents complete
43
43
h. TaskUpdate: phase status = "completed" (agents self-manage their task status)
44
44
```
@@ -164,7 +164,7 @@ Sequential execution is the exception requiring explicit justification. When ass
164
164
---
165
165
166
166
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}")`.
168
168
3.**Check for plan** in `docs/plans/` matching this task
169
169
170
170
### Plan Status Handling
@@ -254,7 +254,7 @@ When a phase is skipped but a coder encounters a decision that would have been h
254
254
1.`TaskCreate(subject="preparer: research {feature}", description="CONTEXT: ...\nMISSION: ...\nINSTRUCTIONS: ...\nGUIDELINES: ...")`
255
255
- Include task description, plan sections (if any), and "Reference the approved plan at `docs/plans/{slug}-plan.md` for full context."
256
256
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.")`
258
258
259
259
Completed-phase teammates remain as consultants. Do not shutdown during this workflow.
260
260
@@ -324,7 +324,7 @@ When detection fires (score >= threshold), follow the evaluation response protoc
324
324
- Do not read phase output files yourself or paste their content into the task description.
325
325
- If PREPARE was skipped: pass the plan's Preparation Phase section instead.
326
326
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.")`
328
328
329
329
Completed-phase teammates remain as consultants. Do not shutdown during this workflow.
330
330
@@ -412,7 +412,7 @@ For each coder needed:
412
412
- 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."
413
413
- 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."
414
414
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.")`
416
416
417
417
Spawn multiple coders in parallel (multiple `Task` calls in one response). Include worktree path and S2 scope boundaries in each task description.
418
418
@@ -475,7 +475,7 @@ Execute the [CONSOLIDATE Phase protocol](../protocols/pact-scope-phases.md#conso
475
475
- Include task description, CODE phase handoff summaries (from SendMessage, not files), plan sections (if any), plan reference.
476
476
- Include: "You own ALL substantive testing: unit tests, integration, E2E, edge cases."
477
477
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.")`
Copy file name to clipboardExpand all lines: pact-plugin/commands/peer-review.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ Review task: in_progress (persists until merge-ready)
85
85
86
86
**PR Review Workflow**
87
87
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}")`.
89
89
90
90
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:
91
91
@@ -105,7 +105,7 @@ Select the domain coder based on PR focus:
105
105
For each reviewer:
106
106
1.`TaskCreate(subject="{reviewer-type}: review {feature}", description="Review this PR. Focus: [domain-specific review criteria]...")`
107
107
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.")`
109
109
110
110
Spawn all reviewers in parallel (multiple `Task` calls in one response).
Copy file name to clipboardExpand all lines: pact-plugin/commands/plan-mode.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,7 @@ Skip specialists clearly not relevant (e.g., skip database engineer for pure UI
97
97
98
98
### Phase 1: Parallel Specialist Consultation
99
99
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}")`.
101
101
102
102
Dispatch relevant specialists **in parallel**, each in **planning-only mode**.
103
103
@@ -177,7 +177,7 @@ If a specialist fails entirely (timeout, error):
177
177
**Dispatch each consultant**:
178
178
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]")`
179
179
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.")`
Copy file name to clipboardExpand all lines: pact-plugin/commands/rePACT.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Run a recursive PACT cycle for this sub-task: $ARGUMENTS
6
6
7
7
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.
8
8
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.
10
10
11
11
---
12
12
@@ -205,10 +205,12 @@ Design the sub-component:
205
205
206
206
Implement the sub-component:
207
207
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}")`.
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.")`
212
214
213
215
For multi-domain: spawn multiple specialists in parallel.
0 commit comments