Add Autonomous Legal War Game — adversarial multi-agent M&A stress-tester#116
Open
fmalik100 wants to merge 2 commits intodocker:mainfrom
Open
Add Autonomous Legal War Game — adversarial multi-agent M&A stress-tester#116fmalik100 wants to merge 2 commits intodocker:mainfrom
fmalik100 wants to merge 2 commits intodocker:mainfrom
Conversation
…tester Implements a full Red Team / Blue Team adversarial pipeline for M&A contract stress-testing using claude-opus-4-6 with adaptive thinking and Pydantic structured outputs. - warroom/models/schemas.py: Pydantic schemas for AttackVector, PlaintiffAnalysis, DefenseAnalysis, and SegmentReport with computed risk scores - warroom/document/processor.py: PDF/TXT ingestion with section-header-aware segmentation, falling back to word-count chunking - warroom/agents/plaintiff.py: Red Team agent — hunts ambiguity, indemnification gaps, liability exposure, and black-swan edge cases (severity 1-5) - warroom/agents/defense.py: Blue Team agent — precision redrafting to neutralise each attack vector while preserving business intent - warroom/orchestrator.py: Drives the pipeline sequentially or in parallel via a thread pool; rich progress display - warroom/report/generator.py: Terminal summary, JSON, and self-contained HTML report generation - main.py: Typer CLI with --parallel, --html, --max-segments, and --words flags Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Agents now automatically interact across multiple rounds: Plaintiff re-attacks the Defense's hardened clause each round, Defense re-patches, until convergence or max rounds is reached. No human intervention required between rounds. Provider abstraction: - warroom/providers/base.py: LLMProvider protocol + make_provider() factory - warroom/providers/anthropic_p.py: Anthropic SDK (claude-opus-4-6, adaptive thinking) - warroom/providers/ollama_p.py: Ollama via OpenAI-compatible endpoint (100% local, free) Multi-round adversarial loop: - warroom/loop/adversarial.py: Plaintiff attacks current clause → Defense hardens → Plaintiff re-attacks hardened clause → repeat until convergence or max_rounds - Convergence detection: stops early when severity drops to threshold (default ≤2) - Severity trajectory tracked per segment (e.g. 4 → 3 → 2 shows convergence) Schema updates (warroom/models/schemas.py): - AdversarialRound: captures one Red→Blue exchange - IterativeSegmentReport: full round history, severity_trajectory, risk_reduction, initial_risk_score, converged property CLI updates (main.py): - --provider anthropic|ollama (default: anthropic) - --model <name> (default varies by provider) - --plaintiff-provider / --plaintiff-model (per-agent overrides for mixing providers) - --defense-provider / --defense-model - --ollama-url (default: http://localhost:11434/v1) - --rounds (default: 3) - --convergence (severity threshold, default: 2) Report updates: terminal + JSON + HTML now show per-round breakdowns, severity trajectories, risk reduction stats, and convergence status. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
legal_warroom/— a standalone Python tool that stress-tests legal documents (M&A agreements, NDAs, etc.) using an adversarial multi-agent simulationclaude-opus-4-6with adaptive thinking) or 100% locally via Ollama (no API costs) with any compatible model (qwen2.5:14b,llama3.1:8b, etc.)Architecture
Test plan
python main.py sample.txt --max-segments 1— single segment dry run (Anthropic)python main.py sample.txt --provider ollama --model llama3.1:8b --max-segments 1— Ollama dry runpython main.py sample.txt --rounds 2 --html— multi-round with HTML reportpython main.py sample.txt --parallel --max-segments 3— parallel processingoutput/🤖 Generated with Claude Code