# devils_advocate A structured debate tool for stress-testing ideas against a devil's advocate. Designed to reduce sycophancy by forcing critical examination of decisions before commitment. --- ## Quick Start ```bash pi /devil we should switch to microservices ``` Or call the tool directly with parameters. --- ## Pi User Implications ### Session Behavior | Aspect | Behavior | |--------|----------| | **Session state** | Debates are stateless. Each call is independent. | | **Conversation history** | Debate results are NOT automatically added to the conversation. | | **Model** | Uses the currently selected model (or configured model). | | **Context** | Does NOT automatically include current conversation context. You must pass it explicitly. | | **API credentials** | Uses current session's API keys. | | **Tool results** | Displayed inline, stored in tool details, but not in conversation history unless you add them. | ### When to Use **Good use cases:** - Before implementing architectural decisions - When you're unsure about a direction and want pushback - After getting too much agreement (sign of sycophancy) - To document concerns for stakeholders **Not ideal for:** - Quick questions (overhead too high) - When you already have strong disagreement (you don't need a devil) - Sensitive topics where disagreement feels personal ### Integration with Workflow ``` 1. You're working on something 2. You get suspicious agreement → /devil 3. Review blocking issues 4. Decide: proceed, revise, or abandon 5. Continue with confidence (or a better idea) ``` ### Passing Context Because debates don't auto-include conversation context: ```javascript // Good: Explicit context devils_advocate({ idea: "Add authentication to this endpoint", context: { current_approach: "API key in query params", security_requirements: "Need OAuth for third-party access", timeline: "Must ship by Friday" } }) // Bad: Missing context (devil won't know your constraints) devils_advocate({ idea: "Add authentication" }) ``` --- ## Configuration Add to `~/.pi/agent/settings.json`: ```json { "devilsAdvocate": { "model": "anthropic/claude-haiku-4-5", "maxRounds": 5, "stoppingConditions": "consensus", "concessionThreshold": 0.7, "onBlocking": "surface" } } ``` ### Settings Reference | Setting | Type | Default | Description | |---------|------|---------|-------------| | `model` | string | current model | Model for debates. Use cheaper models for speed. | | `maxRounds` | number | 5 | Maximum debate rounds (1-10). | | `stoppingConditions` | string | "consensus" | When to stop debating. | | `concessionThreshold` | number | 0.7 | How much concession triggers early stop (0.0-1.0). | | `onBlocking` | string | "surface" | What to do with blocking issues. | ### Stopping Conditions | Value | Behavior | |-------|----------| | `consensus` | Stop after 2 consecutive rounds with significant resolutions. | | `blocking_found` | Stop as soon as no blocking issues remain. | | `max_rounds` | Always run full `maxRounds`. | | `user_stops` | (Future: user-controlled stopping.) | ### On Blocking Behavior | Value | Behavior | |-------|----------| | `surface` | Always show blocking issues in output. | | `escalate` | Add warning if blocking issues found. | | `ignore` | Don't flag blocking issues (not recommended). | --- ## Parameters ```javascript devils_advocate({ idea: string, // Required: what to debate context?: object, // Optional: { key: "value" } pairs model?: string, // Optional: override model maxRounds?: number, // Optional: 1-10 stakeholder?: string, // Optional: focus area stoppingConditions?: string, // Optional: when to stop concessionThreshold?: number, // Optional: 0.0-1.0 onBlocking?: string, // Optional: blocking behavior output?: string // Optional: "full" or "summary_only" }) ``` ### Stakeholder Focus | Value | Focus | |-------|-------| | `security` | Security concerns, attack vectors, vulnerabilities | | `cost` | Cost, ROI, resource implications, scaling costs | | `ux` | User experience, accessibility, friction points | | `implementation` | Technical complexity, dependencies, maintenance | | `ethics` | Ethical concerns, societal impact, fairness | | `skeptical` | General skepticism, challenged assumptions | --- ## Output Format ### Challenge Classification Each challenge is classified: | Classification | Meaning | Action | |---------------|---------|--------| | **blocking** | Would prevent the idea from working | Must address first | | **addressable** | Valid concern with known mitigations | Consider mitigations | | **assumed** | Based on premises that may not hold | Verify assumptions | | **minor** | Aesthetic or edge case | Not worth debating | ### Recommendation | Value | Meaning | |-------|---------| | `proceed` | No blocking issues, idea holds up | | `proceed_with_caution` | Addressable concerns exist | | `revise` | Blocking issues require design changes | | `abandon` | Fundamental flaws identified | ### Example Output ```markdown ## Summary **Recommendation:** proceed_with_caution ### Blocking Issues (must address first) - Vendor lock-in → Use abstraction layer or multi-cloud strategy ### Addressable Concerns (valid concerns with mitigations) - Migration complexity → Use migration tooling (Alembic, Flyway) ### What Survived Scrutiny - SQLite handles our current read/write volume - Simple deployment model reduces ops burden ### What Was Conceded - WAL mode limits concurrent read performance at scale ### Recommended Next Steps 1. Define cloud abstraction layer 2. Benchmark with production data volume 3. Prototype migration strategy *Debate: 3 rounds | Blocking: 1* ``` --- ## Examples ### Basic Usage ``` devils_advocate({ idea: "We should migrate from REST to GraphQL" }) ``` ### With Context ``` devils_advocate({ idea: "Use SQLite as primary database", context: { scale: "10k concurrent users", team_size: "5 developers", requirement: "ACID compliance required", timeline: "MVP by Q2" } }) ``` ### Focused Challenge ``` devils_advocate({ idea: "Add real-time notifications", stakeholder: "implementation", stoppingConditions: "blocking_found" }) ``` ### Full Debate with All Parameters ``` devils_advocate({ idea: "Implement OAuth2 authentication", context: { current: "API keys in headers", users: "1000 monthly active", security_level: "medium" }, model: "anthropic/claude-sonnet-4-5", maxRounds: 3, stakeholder: "security", stoppingConditions: "consensus", concessionThreshold: 0.8, onBlocking: "escalate", output: "full" }) ``` --- ## Best Practices ### Writing Good Ideas **Good:** - "Add rate limiting to the API" - "Use event sourcing for order management" - "Implement dark mode across all screens" **Bad:** - "Improve performance" (vague) - "Make it better" (unmeasurable) - "Add auth" (missing context) ### Providing Context Context is critical for relevant challenges: ``` // Include relevant constraints context: { current_approach: "What you're doing now", constraints: "What limits you", requirements: "What must be preserved", timeline: "When it needs to ship" } ``` ### Interpreting Results - **Multiple blocking issues**: Revise the idea significantly - **Addressable concerns only**: Proceed with mitigations planned - **Survived full debate**: Good confidence in the idea - **Early stop (consensus)**: Either the idea is solid or concessions were too easy --- ## Limitations 1. **No conversation memory**: Each debate is independent 2. **LLM classification**: Challenge classification depends on model interpretation 3. **Concession detection**: Keyword matching can be fooled 4. **No escalation actions**: Blocking issues are surfaced, not acted upon 5. **Model-dependent quality**: Challenge quality varies by model --- ## Troubleshooting ### "No model available" - Select a model first with `/model` - Or configure `devilsAdvocate.model` in settings ### "Debate took too long" - Reduce `maxRounds` - Use a faster model (haiku vs opus) - Use `stoppingConditions: "blocking_found"` ### "Challenges aren't relevant" - Provide more specific `context` - Use `stakeholder` to focus the challenge domain - Refine your `idea` to be more specific ### "Too many minor challenges" - Use `stakeholder: "skeptical"` for priority concerns - Add `context.constraints` to narrow scope --- ## Related - `/compact` - Summarize conversation (use after debate) - `/tree` - Review decision history - `/fork` - Branch on different decisions