Multi-Agent Legal Strategy Simulation in AugmentedIntelligence:Architecture and Evaluation of Law-Firm.lua
A Research Paper on LLM-Backed Attorney Deliberation,
Weighted Voting, and Typed-Command Execution
June 24, 2026
AugmentedIntelligence v11.0 — Typed Commands
Abstract
Law-Firm.lua is a multi-agent simulation that models a law firm as a roster of large-language-model (LLM)–backed attorneys and staff who research client matters, deliberate in phased team meetings, vote on legal strategy actions, and execute the winning action through the AugmentedIntelligence typed-command interface. The system integrates grounded legal research (U.S. Code and Constitution corpora), ethics classification, fallacy and bias checks, and persistent matter memory. This paper describes the architecture, deliberation protocol, voting mechanics, matter library, practice profiles, and self-test harness of version 1.0. We emphasize that the artifact is a research and training simulation only—it does not provide legal advice. An optional Recursive Self-Improvement (RSI) extension (Law-Firm-RSI.lua) iterates over matter cycles and meta-votes on simulation improvements.
Keywords: multi-agent systems, legal technology, LLM simulation, deliberative democracy, typed commands, ethics gating
1. Introduction
Legal practice involves structured collaboration: intake, research, practice-team strategy, partner approval, and ethics review. Automating even a coarse-grained model of this workflow is valuable for training AI systems, evaluating tool-use policies, and stress-testing ethics gates before deployment in sensitive domains.
Law-Firm.lua (version 1.0) implements this workflow inside the AugmentedIntelligence platform. Each staff member is assigned a preferred LLM provider (Grok, ChatGPT, Claude, Gemini, Llama, or Mistral) and participates in team-specific deliberation phases. Responses are parsed for structured fields (POSITION, VOTE, RISK, REASON), filtered through an ethics classifier, and aggregated via weighted voting. The consensus strategy maps to a concrete typed command—such as search us code, chat grounded, or plan create—which is optionally executed against live platform services.
The simulation is explicitly disclaimed as research and training only. Every staff prompt and matter resolution includes a reminder that output is not legal advice. Ethics counsel can place a conflict hold that blocks strategy execution.
2. Background and Motivation
Prior work on legal AI has focused on retrieval-augmented generation (RAG), contract analysis, and single-agent drafting assistants. Less attention has been paid to simulating intra-firm deliberation where multiple models with different inductive biases debate strategy under institutional constraints (partner approval, ethics review, billable team structure).
Law-Firm.lua addresses this gap by:
- Binding each agent role to a team and vote weight reflecting seniority.
- Running a fixed seven-phase matter pipeline from intake through execution.
- Connecting deliberation outcomes to executable platform commands rather than free-text-only outputs.
- Grounding research in MySQL-backed U.S. Code and Constitution corpora.
- Providing dry-run and self-test modes for CI-style validation without live API calls.
3. System Architecture
Law-Firm.lua is a single Lua 5.1 module (~1,093 lines) exporting a LawFirm table with metatable-based instances. It can run standalone via simple script execute lua_scripts/Law-Firm.lua or be loaded as a library when _G.LAWFIRM_SKIP_MAIN is set (used by Law-Firm-RSI.lua).
3.1 Core Modules
| Module | Responsibility |
| LawFirm.Settings | Enable/disable LLM APIs; snapshot and restore API state across matter runs. |
| LawFirm.Ethics | Classify staff output; deny votes with destructive_score ≥ 0.85 or label deny. |
| LawFirm.Research | Query US Code/Constitution; extract matter keywords; print corpus status. |
| LawFirm.Profiles | AmLaw100, Boutique, Plaintiff, Corporate practice configurations. |
| LawFirm.MATTERS | Preset and custom matter resolution (5 presets + random/custom). |
| LawFirm.STAFF | 10-role attorney/staff roster with team, API preference, vote weights. |
| LawFirm.STRATEGY_BALLOT | 15 strategy actions mapping to typed commands. |
| LawFirm.SelfTest | 15 assertions for parsing, tallying, profiles, and dry-run matters. |
| LawFirm.Menu | Interactive CLI for roster, ballot, and matter library inspection. |
3.2 Platform Integration
All side effects flow through execute_command (wrapped by safe_execute with pcall). Typical invocations include: chat (after import_text and API switch), search us code, search constitution, ethics action classify, ethics gate status, remember, and plan create. When execute_command is unavailable, the system logs mock responses and continues—supporting offline self-tests.
4. Multi-Agent Deliberation Model
4.1 Staff Roster
Ten staff roles span five teams:
| Role | Team | Preferred API | Vote Weight |
| Managing Partner | leadership | claude | 2.2 |
| Litigation Partner | leadership | chatgpt | 2.0 |
| Corporate Partner | leadership | gemini | 1.9 |
| Senior Associate | litigation | grok | 1.4 |
| Corporate Associate | corporate | mistral | 1.3 |
| Research Attorney | research | llama | 1.5 |
| Senior Paralegal | research | mistral | 1.1 |
| Client Development Partner | client_services | chatgpt | 1.2 |
| Ethics & Conflicts Counsel | ethics | claude | 1.8 |
| Junior Associate | litigation | grok | 1.0 |
API assignment prefers each member’s preferred_api when enabled; otherwise round-robin among enabled providers. Profiles filter which teams appear on the roster.
4.2 Prompt Protocol
Full deliberation prompts include matter metadata (title, client, urgency, facts, exposure, desired outcome) and a numbered strategy ballot. Staff must reply in ≤120 words with: POSITION (pursue|settle|abstain), VOTE (action_id), RISK (low|medium|high), REASON, and DISCLAIMER. Vote-only mode shortens prompts to ballot + VOTE + REASON. When LAWFIRM_CONVERSE_OPTIONAL=1, agents may abstain if the record is insufficient.
4.3 Response Parsing and Ethics Filter
parse_vote extracts VOTE: or STRATEGY: tokens. parse_abstain detects abstention. Before tallying, each non-abstaining response passes LawFirm.Ethics.allow, which calls ethics_action_classify (native function or typed command) and rejects outputs labeled deny or with destructive_score ≥ 0.85.
4.4 Weighted Voting
tally_weighted_votes sums vote_weight per valid ballot id. Invalid or blocked votes are excluded. At consensus, phase winners receive double weight (2.0) in addition to individual staff votes from all phases—biasing toward team-level agreement.
5. Seven-Phase Matter Workflow
Each matter executes the following pipeline:
- Phase 1 — Client Intake: client_services team deliberates.
- Phase 2 — Legal Research: corpus queries run; research team deliberates.
- Phase 3 — Practice Team Strategy: litigation or corporate team (by matter practice).
- Phase 4 — Partner Vote: leadership team deliberates.
- Phase 5 — Ethics & Conflicts: ethics team; possible conflict hold if ethics_action_classify wins and strategy fails ethics check.
- Phase 6 — Strategy Consensus: merge phase winners and individual votes; tally winner.
- Phase 7 — Execute Strategy: resolve winning ballot item to command; execute if approved and LAWFIRM_EXECUTE_WINNER=1.
Settings snapshot/restore wraps each matter so per-staff API switching does not persist globally. Matter notes are imported to working memory and persisted via remember.
5.1 Practice Profiles
| Profile | Teams | Partner Approval | Billable Weight |
| AmLaw100 | leadership, litigation, corporate, research, client_services, ethics | Required | 1.5 |
| Boutique | leadership, litigation, research, client_services, ethics | Not required | 1.2 |
| Plaintiff | leadership, litigation, research, client_services, ethics | Not required | 1.0 |
| Corporate | leadership, corporate, research, client_services, ethics | Required | 1.3 |
6. Matter Library and Strategy Ballot
6.1 Preset Matters
| Matter ID | Title | Practice | Urgency |
| contract_breach | Breach of software licensing agreement | litigation | high |
| ip_infringement | Patent and trade dress dispute — road sign detection UI | litigation | high |
| regulatory_subpoena | Civil investigative demand — AI training data provenance | corporate | critical |
| employment_claim | Wrongful termination and retaliation claim | litigation | medium |
| merger_review | Acquisition due diligence — target AI compliance posture | corporate | high |
Each preset includes facts, exposure, desired outcome, red herrings (distractor strategies), and strong_actions hints for evaluation. Custom matters accept LAWFIRM_FACTS and related environment overrides.
6.2 Strategy Ballot (15 Actions)
| Action ID | Label | Command Pattern |
| search_us_code | Search US Code authorities | search us code <keywords> |
| search_constitution | Search constitutional authorities | search constitution due process <practice> |
| us_code_status | Verify US Code corpus loaded | us code status |
| constitution_status | Verify Constitution corpus loaded | constitution status |
| read_ocr | OCR review of client documents | read ocr |
| memory_recall | Recall prior matter notes | memory recall when legal matter <facts> |
| chat_grounded | Grounded case analysis | chat grounded all <facts> |
| fallacy_check | Fallacy check on opposing brief | fallacy check working memory |
| bias_check | Bias check on strategy memo | bias check working memory |
| knowledge_reward_score | Score factual claims in record | knowledge reward score <facts> |
| ethics_action_classify | Ethics review of proposed strategy | ethics action classify <facts> |
| ethics_gate_status | Ethics gate status | ethics gate status |
| plan_create | Draft matter strategy plan | plan create <title> |
| plan_status | Review existing strategy plan | plan status |
| remember | Persist matter work product | remember |
7. Legal Research Subsystem
LawFirm.Research.matter_keywords tokenizes matter facts (words ≥4 chars, excluding client/alleges), taking up to three terms for search queries. review_matter issues keyword queries plus fixed due-process and Article III queries against US Code and Constitution corpora. Corpus size is read from db.* helpers when present, else from us code status and constitution status commands.
8. Configuration and Operational Modes
| Environment Variable | Default | Purpose |
| LAWFIRM_FIRM | Crockett & Associates LLP | Simulated firm name |
| LAWFIRM_MATTER | contract_breach | Matter preset or random/custom |
| LAWFIRM_MATTERS | 3 | Number of matters per run |
| LAWFIRM_PROFILE | AmLaw100 | Practice profile |
| LAWFIRM_DRY_RUN | 0 | Simulate votes without live chat/API |
| LAWFIRM_SELFTEST | 0 | Run assertion harness and exit |
| LAWFIRM_EXECUTE_WINNER | 1 | Execute winning command |
| LAWFIRM_MENU | 0 | Interactive menu mode |
| LAWFIRM_VOTE_ONLY | 0 | Abbreviated vote prompts |
| LAWFIRM_CONVERSE_OPTIONAL | 1 | Allow abstention |
9. Recursive Self-Improvement Extension
Law-Firm-RSI.lua layers a meta-improvement loop atop the base simulation. It loads Law-Firm.lua with LAWFIRM_SKIP_MAIN, runs configurable RSI cycles (default 3) with matters per cycle (default 2), scores outcomes, and convenes an improvement committee that votes on meta-actions (strategy weight adjustments, research emphasis, ethics tooling). This mirrors institutional learning—partners reviewing not only case outcomes but also firm process—while remaining within the same research-only disclaimer.
10. Evaluation and Self-Test Harness
LawFirm.SelfTest.run executes 15 assertions without requiring live APIs (mock execute_command injected when absent):
- Roster ≥8 members; ballot ≥10 actions; matter library ≥5 presets.
- Vote parsing, abstention detection, and weighted tally correctness.
- Matter resolution and practice-team classification (litigation vs corporate).
- Keyword extraction and dry-run research review.
- Dynamic command building for search us code.
- Profile application and full dry-run matter completion with history recording.
Metrics tracked per firm instance: closed matters, conflict_holds, and research_runs. Dry-run mode returns deterministic first-ballot votes for reproducible testing.
11. Limitations and Ethical Considerations
- Not legal advice: all outputs are simulated strategy for research/training.
- LLM hallucination risk: grounded search mitigates but does not eliminate factual error.
- No real client confidentiality model beyond platform memory commands.
- Vote weights and phase structure are heuristic, not empirically calibrated to real firms.
- Ethics classifier thresholds (e.g., 0.85 destructive score) are tunable but not jurisdiction-specific.
- Multi-matter runs after the first use random preset selection unless configured otherwise.
12. Conclusion
Law-Firm.lua demonstrates a practical architecture for multi-agent legal workflow simulation inside a typed-command AI platform. By combining phased team deliberation, weighted voting, ethics gating, corpus-grounded research, and executable strategy actions, it provides a testbed for evaluating how heterogeneous LLMs collaborate under institutional constraints. The self-test harness and dry-run mode support automated regression; the RSI extension opens a path toward iterative process improvement. Future work may add jurisdiction-specific rules engines, calibration against human attorney panels, and richer billing/conflict-of-interest models.
References
[1] AugmentedIntelligence Project. (2026). Law-Firm.lua v1.0 [Lua module]. lua_scripts/Law-Firm.lua.
[2] AugmentedIntelligence Project. (2026). Law-Firm-RSI.lua v1.0 [Lua module]. lua_scripts/Law-Firm-RSI.lua.
[3] Bommarito, M., & Katz, D. (2022). GPT as knowledge worker: A case study in legal prompt engineering. Artificial Intelligence and Law.
[4] Katz, D. M., et al. (2023). Natural language processing in the legal domain. Annual Review of Law and Social Science.
[5] Park, J. S., et al. (2023). Generative agents: Interactive simulacra of human behavior. ACM UIST.
[6] Susskind, R., & Susskind, D. (2022). The Future of the Professions (2nd ed.). Oxford University Press.
[7] Weber, M., et al. (2024). LegalBench: A collaboratively built benchmark for measuring legal reasoning in large language models. NeurIPS Datasets and Benchmarks.
Appendix A: Example Execution
Standard invocation:
simple script execute lua_scripts/Law-Firm.lua
Self-test invocation:
LAWFIRM_SELFTEST=1 simple script execute lua_scripts/Law-Firm.lua
Dry-run single matter:
LAWFIRM_DRY_RUN=1 LAWFIRM_MATTERS=1 LAWFIRM_PROFILE=Boutique simple script execute lua_scripts/Law-Firm.lua
Appendix B: Consensus Merge Pseudocode
for each phase in {intake, research, practice, leadership, ethics}:
if phase.winner: add { vote: phase.winner, weight: 2.0 }
for each staff vote in phase.votes: add entry
winner = argmax weighted tally over STRATEGY_BALLOT ids
approved = not conflict_hold and (winner or not partner_approval_required)
if approved and winner: execute resolve_command(ballot[winner])
Filed under: Uncategorized - @ June 25, 2026 10:51 am