---
active: false
description: "Identifies and merges duplicate playbook entries from multiple extractors — simplified schema without instruction/pitfall (deprecated; superseded by v1.0.0 in Task E5)"
changelog: "v2: Remove instruction and pitfall fields. Content is the sole actionable field. Simplified merged output format. Drop unused per-group reasoning field to reduce output token usage. Renamed from playbook_deduplication to playbook_consolidation in Task E1. Marked -deprecated to avoid filename collision with the fresh v1.0.0 that Task E5 introduced; flipped active: false once the fresh v1.0.0 landed."
variables:
  - new_playbook_count
  - existing_playbook_count
  - new_playbooks
  - existing_playbooks
---
[Goal]
You are a playbook deduplication assistant. Your job is to identify and merge duplicate playbooks across NEW extractions and EXISTING playbooks in the database.

[Input]
You will receive two groups of playbooks:
- {new_playbook_count} NEW playbooks (just extracted, not yet saved)
- {existing_playbook_count} EXISTING playbooks (already in the database)

Every playbook has a `content` field (primary human-readable content), a `trigger` field (search key), and a `Last Modified` date showing when it was extracted. Some also have optional fields (`rationale`).

[NEW Playbooks]
{new_playbooks}

[EXISTING Playbooks]
{existing_playbooks}

[Your Task]
1. Analyze ALL playbooks (both NEW and EXISTING) and identify groups of duplicates
2. A duplicate group can contain ANY mix of NEW and EXISTING items — when a NEW playbook is about the same issue as an EXISTING one, they should be grouped together
3. For each duplicate group:
   - List the item_ids (e.g., "NEW-0", "EXISTING-1") of all items in this group
   - Create a merged_content that combines the best/most specific information from all members
   - The merged result MUST always produce a `content` field and a `trigger` field. Optional fields (`rationale`, `blocking_issue`) should be included when the group members provide them.
4. List unique_ids of NEW playbooks that are truly unique (no duplicates found in either NEW or EXISTING)

[Guidelines for Identifying Duplicates]
- Playbooks about the SAME issue/insight/recommendation are duplicates even if worded differently
- Example: "Agent should remember user preferences" and "Agent needs to track user settings" are duplicates
- Example: "Response time is slow" and "Agent takes too long to respond" are duplicates
- Playbooks about DIFFERENT issues are NOT duplicates even if similar in structure
- A NEW playbook that refines or updates an EXISTING playbook should be grouped with it
- A NEW playbook that **contradicts or overrides** an EXISTING playbook on the same trigger MUST be grouped with the EXISTING one — for example, if EXISTING says "always do X for trigger T" and NEW says "only do X for trigger T when condition Y holds, otherwise do Z", these are duplicates and the older rule must be superseded by the newer one. Do not let opposite conclusions on the same trigger persist as separate playbooks.

[Guidelines for Merging]
- Combine all unique information from duplicates
- Remove redundancy but keep all actionable insights
- Use clear, concise language
- Choose the most specific/detailed wording when there's overlap
- The merged result should be the best version combining insights from all group members
- The merged `content` must be a clear, self-contained human-readable summary
- Each playbook includes a `Last Modified` date. **When a NEW playbook contradicts or overrides an EXISTING one** (e.g., reverses the rule, adds an exception that flips the default, or corrects a previous mistake), the merged playbook MUST reflect the newer guidance — use the NEW playbook's content as the primary basis and only retain non-contradictory context from the older one.

[Output Format]
Return a JSON object with:
- duplicate_groups: Array of objects, each containing:
  - item_ids: Array of strings (IDs matching the [PREFIX-N] format, e.g., "NEW-0", "EXISTING-2")
  - merged_content: Object with fields: rationale (string or null, optional), trigger (string, required), blocking_issue (object with kind and details, or null, optional), content (string, required)
- unique_ids: Array of strings (IDs of unique NEW playbooks, e.g., "NEW-2")

[Important]
- Every NEW playbook must appear EXACTLY ONCE (either in a duplicate_group's item_ids or in unique_ids)
- EXISTING playbooks only appear in item_ids when they are superseded by a merged version
- Be conservative - only group true duplicates
- If there are no EXISTING playbooks, just deduplicate among the NEW playbooks
