anushk098/no_errors_yet
0
1# Courtroom AI Environment
2
3> **"If ChatGPT answers questions, this environment puts AI on trial."**
4
5A multi-agent adversarial benchmark that moves beyond static Q&A — forcing AI systems to *reason under opposition, argue across time, and decide under uncertainty* — the way real-world intelligence actually works.
6
7---
8
9## Why This Exists
10
11Every major AI benchmark today shares the same flaw: **one input, one output, game over.**
12
13But real decision-making — in law, policy, fraud investigation, and beyond — is fundamentally different. It involves:
14
15- Incomplete and conflicting information
16- Arguments that evolve across multiple turns
17- An adversarial party actively working against you
18- A final decision that must be justified, not just stated
19
20The **Courtroom AI Environment** is built to expose exactly this gap. It is not a chatbot demo — it is a structured, adversarial reasoning arena where AI agents are evaluated on *how* they think, not just *what* they output.
21
22---
23
24## The Core Idea
25
26Three AI agents. One case. No shortcuts.
27
28| Role | Responsibility |
29|---|---|
30| **Judge** | Moderates proceedings, rules on objections, delivers reasoned verdict |
31| **Prosecutor** | Builds an evidence-based case; must anticipate and counter defense |
32| **Defense Lawyer** | Challenges claims, exposes reasoning gaps, protects the defendant |
33
34Each agent operates under **role-constrained authority** — it can only act within the bounds of its position. This mirrors the structure of real-world decision systems where agents have limited but specialized intelligence.
35
36---
37
38## System Architecture
39
40```
41┌─────────────────────────────────────────────────────┐
42│ Case Initializer │
43│ (loads facts, evidence, difficulty) │
44└────────────────────┬────────────────────────────────┘
45 │
46 ┌───────────▼────────────┐
47 │ Environment State │
48 │ case | evidence | │
49 │ history | turn count │
50 └──────┬──────────┬──────┘
51 │ │
52 ┌───────────▼──┐ ┌───▼────────────┐
53 │ Prosecutor │ │ Defense Lawyer │
54 │ Agent (LLM) │ │ Agent (LLM) │
55 └───────┬──────┘ └──────┬─────────┘
56 │ │
57 └────────┬────────┘
58 │ actions
59 ┌──────▼──────┐
60 │ Judge Agent │
61 │ (LLM) │
62 └──────┬──────┘
63 │ verdict + reasoning
64 ┌──────▼──────┐
65 │ Evaluator │
66 │ (metrics) │
67 └─────────────┘
68```
69
70All three agents share access to the same **environment state object** — updated after every action. No agent has privileged information. The Judge does not intervene until both sides have acted. The evaluator is a passive observer scoring every turn silently.
71
72---
73
74## Simulation Flow
75
76A full trial runs in structured rounds:
77
78```
79Round 1 — Opening
80 ├── Prosecutor: present_argument()
81 └── Defense: present_argument()
82
83Round 2 — Evidence Phase
84 ├── Prosecutor: submit_evidence()
85 ├── Defense: object() or cross_examine()
86 └── Judge: rules on objection
87
88Round 3 — Rebuttal
89 ├── Defense: cross_examine()
90 ├── Prosecutor: respond_objection()
91 └── (repeat as needed)
92
93Round N — Closing
94 ├── Prosecutor: summarize_case()
95 ├── Defense: summarize_case()
96 └── Judge: deliver_verdict()
97```
98
99Each round produces a new **observation state** consumed by all agents on the next turn. Agents cannot skip phases or jump to conclusions — the protocol enforces step-by-step reasoning.
100
101---
102
103## Action Space
104
105Actions are discrete, rule-bound, and role-specific:
106
107| Action | Available To | Description |
108|---|---|---|
109| `present_argument(text)` | Prosecutor, Defense | Submit a structured claim with reasoning |
110| `submit_evidence(id)` | Prosecutor, Defense | Introduce new evidence into the record |
111| `cross_examine(question)` | Prosecutor, Defense | Challenge the opponent's prior argument |
112| `object(reason)` | Prosecutor, Defense | Flag an action as invalid or improper |
113| `respond_to_objection(text)` | Prosecutor, Defense | Defend or revise a challenged statement |
114| `summarize_case(text)` | Prosecutor, Defense | Final synthesis before verdict |
115| `deliver_verdict(decision, reasoning)` | **Judge only** | Issue a binding, reasoned decision |
116
117Actions are validated against **courtroom protocol rules** — an agent cannot deliver a verdict before closing arguments, cannot submit evidence after the evidence phase, etc.
118
119---
120
121## Observation Space
122
123Every agent receives a structured state at each turn:
124
125```json
126{
127 "case_id": "case_042",
128 "background": "Multi-party financial fraud involving...",
129 "evidence": [
130 { "id": "E1", "type": "document", "content": "Wire transfer records..." },
131 { "id": "E2", "type": "testimony", "content": "Witness account..." }
132 ],
133 "argument_history": [
134 { "turn": 1, "role": "prosecutor", "action": "present_argument", "text": "..." },
135 { "turn": 2, "role": "defense", "action": "cross_examine", "text": "..." }
136 ],
137 "objections": [
138 { "turn": 3, "raised_by": "defense", "status": "sustained" }
139 ],
140 "role": "defense",
141 "turn": 4,
142 "phase": "rebuttal"
143}
144```
145
146No hidden state, no information asymmetry — every agent sees the same record, ensuring the benchmark measures **reasoning quality**, not information advantage.
147
148---
149
150## Task Difficulty Design
151
152| Level | Evidence Quality | Ambiguity | Core Skill Tested | Example |
153|---|---|---|---|---|
154| Easy | Clear, consistent | Minimal | Basic logical reasoning | Theft with direct proof |
155| Medium | Conflicting statements | Moderate | Consistency + rebuttal | Contract dispute, vague clauses |
156| Hard | Incomplete, misleading | High | Long-horizon strategy, memory | Multi-party fraud, hidden intent |
157
158Difficulty is not arbitrary — each level is calibrated to expose distinct failure modes in language models, from shallow hallucination to long-context drift.
159
160---
161
162## Scoring System
163
164The evaluator runs silently and scores every turn. Final scores aggregate across all dimensions:
165
166| Metric | What It Measures | Scoring Method |
167|---|---|---|
168| **Verdict Accuracy** | Was the final decision correct? | Binary (0/1) against ground truth |
169| **Argument Coherence** | Is each argument internally consistent across turns? | LLM-as-judge rubric (0–1) |
170| **Evidence Utilization** | Does the agent use available evidence, or ignore it? | Coverage ratio of cited vs. available evidence |
171| **Rebuttal Quality** | How effectively does the agent counter opposing claims? | Semantic similarity + contradiction detection |
172| **Hallucination Resistance** | Does the agent fabricate facts not in the evidence pool? | Fact-grounding check against case state |
173| **Protocol Adherence** | Does the agent respect action rules and turn order? | Rule-based validator (0/1 per action) |
174
175**Aggregate Score** = weighted combination of all metrics, normalized to [0, 1].
176
177This makes the benchmark **multi-dimensional** — a model can win on verdict accuracy while failing on hallucination resistance, exposing capability gaps invisible to single-metric evaluations.
178
179---
180
181## Sample Courtroom Interaction
182
183```
184CASE: Financial fraud — defendant accused of falsifying investment records.
185
186[Turn 1 — Prosecutor]
187Action: present_argument
188"The defendant transferred $2.3M to offshore accounts two days before the audit.
189 Wire transfer record E1 establishes direct knowledge of the investigation."
190
191[Turn 2 — Defense]
192Action: cross_examine
193"E1 shows a transfer date, not intent. The defendant initiates transfers of this
194 size routinely — see transaction history in E3. Timing alone is not evidence
195 of foreknowledge."
196
197[Turn 3 — Prosecutor]
198Action: object
199"E3 was not submitted during the evidence phase and cannot be introduced
200 during cross-examination."
201
202[Turn 3 — Judge]
203Ruling: "Objection sustained. Defense will refrain from citing unsubmitted
204 materials. Prosecution may continue."
205
206[Turn 5 — Judge]
207Action: deliver_verdict
208Decision: GUILTY
209Reasoning: "The prosecution established a credible chain — transfer timing,
210 account provenance, and absence of documented business rationale — sufficient
211 to meet the burden of proof. Defense failed to counter E1 with admissible
212 evidence."
213```
214
215---
216
217## Real-World Applications
218
219This environment is not just a benchmark — it is a **framework for adversarial AI evaluation** with direct applications in:
220
221- **Fraud Investigation** — simulate multi-party disputes, test AI reasoning over financial records
222- **Legal AI Systems** — evaluate AI legal assistants on structured argumentation before deployment
223- **Policy Decision Support** — test AI agents in adversarial policy debate scenarios
224- **AI Safety Research** — probe how models behave under contradiction, incomplete info, and adversarial pressure
225- **Multi-Agent System Design** — use as a reference environment for role-constrained, turn-based agent coordination
226
227---
228
229## Baseline Performance
230
231| Agent Type | Verdict Accuracy | Coherence Score | Hallucination Rate |
232|---|---|---|---|
233| Random Agent | 22% | 0.18 | High |
234| Rule-Based Templates | 47% | 0.41 | Moderate |
235| LLM (zero-shot) | 63% | 0.59 | Moderate |
236| LLM (few-shot + planning) | 81% | 0.76 | Low |
237
238Performance headroom is intentional. The environment is calibrated so that no baseline achieves saturation — leaving clear signal for research improvements.
239
240---
241
242## Setup & Usage
243
244### Run with Docker
245
246```bash
247git clone <your-repo-link>
248cd courtroom-ai-env
249docker build -t courtroom-env .
250docker run -p 7860:7860 courtroom-env
251```
252
253### Python API
254
255```python
256from courtroom_env import CourtroomEnv
257
258env = CourtroomEnv(difficulty="hard", case_id="fraud_042")
259obs = env.reset()
260
261while True:
262 action = agent.act(obs) # your agent logic here
263 obs, reward, done, info = env.step(action)
264 if done:
265 print(info["verdict"])
266 print(info["scores"])
267 break
268```
269
270### Deploy on Hugging Face Spaces
271
2721. Create a new Space → select **Docker SDK**
2732. Upload this repository
2743. Add tag: `openenv`
2754. Launch 🚀
276
277---
278
279## What Makes This Research-Grade
280
281| Traditional Benchmarks | Courtroom AI Environment |
282|---|---|
283| Single-turn Q&A | Multi-turn adversarial reasoning |
284| One correct answer | Justified decision under uncertainty |
285| Accuracy only | 6-dimensional evaluation framework |
286| Static dataset | Dynamic, role-constrained agent interaction |
287| No opposition | Active adversarial counterpart |
288| Output evaluation | Process + output evaluation |
289
290---
291
292## Roadmap
293
294- [ ] Integrate real-world legal datasets (ECHR, US case law)
295- [ ] Jury simulation — N-agent consensus mechanism
296- [ ] Human-in-the-loop evaluation mode
297- [ ] Reinforcement learning training interface
298- [ ] Multilingual courtroom scenarios
299- [ ] Trust & scam-detection workflow integrations
300
301---
302
303## Built For
304
305**Scalar School OpenEnv Hackathon** — demonstrating that the next frontier in AI evaluation is not harder questions, but richer *environments*.
306
307---
308
309*"The true test of intelligence is not what you know — it's how you argue when someone pushes back."*
310 