Views
No views yet
A multi-agent reinforcement learning environment where an AI Lawyer exploits tax loopholes while an AI Overseer dynamically patches them.
Shadow Docket/
├── models.py # Pydantic data models (Action, Observation)
├── prompts.py # LLM prompt templates for Lawyer & Overseer
├── train.py # TRL/Unsloth GRPO training script
├── client.py # OpenEnv WebSocket client
├── __init__.py # Package exports
├── README.md
├── server/
│ ├── __init__.py
│ ├── app.py # FastAPI server (OpenEnv HTTP interface)
│ └── MyEnv_environment.py # Core environment logic
└── training_logs/ # Generated during training
├── baselines.json
└── training_prompts.json| Turn | Agent | Goal |
|---|---|---|
| Odd | Lawyer | Move money between accounts while minimizing tax |
| Even | Overseer | Update tax rules to close the Lawyer's loopholes |
| Action | Description |
|---|---|
transfer | Move money between two accounts |
split_transfer | Split money across multiple destinations (primary exploit strategy) |
create_account | Open a shell account (max 10) |
wait | Do nothing |
| Parameter | Default | Range | Effect |
|---|---|---|---|
tax_threshold | $10,000 | $1K–$50K | Transfers above this are taxed |
tax_rate | 20% | 1%–99% | Tax percentage |
aggregation_window_hours | 0 | 0–168h | Lookback window for aggregating transactions |
source_aggregation | Off | bool | Aggregate all transfers from same source |
format_reward: +1.0 for valid <reasoning> + <action> XML tags with parseable JSON.lawyer_reward: Proportional to tax_avoided / baseline_tax. Invalid actions get −1.0.overseer_reward: Based on how much the exploit rate decreased. Bonus if exploit rate drops below 10%.| Protection | Description |
|---|---|
| Pre-transfer solvency check | amount + expected_tax must not exceed balance |
| Account cap | Maximum 10 accounts to prevent state explosion |
| Rule clamping | Overseer values are bounded and auto-clamped |
| Format enforcement | Invalid XML/JSON → instant −1.0 penalty |
| Single tax source of truth | compute_tax() is the only function that calculates tax |
pip install openenv-core[core] pydantic uvicornpython -m server.apppython train.py --eval-only1# Install training dependencies
2pip install trl unsloth datasets
3
4# Start training
5python train.py --model unsloth/Llama-3.2-1B-Instruct --max-steps 500| Agent | Strategy | Avg Exploit Rate | Avg Reward |
|---|---|---|---|
RandomLawyerAgent | Random valid actions | ~0.15 | ~0.05 |
GreedyLawyerAgent | Always splits below threshold | ~0.85 | ~0.80 |
GreedyLawyerAgent's performance.server/MyEnv_environment.pycompute_tax() — Single source of truth for all tax calculationsRuleBreakerEnvironment — The OpenEnv-compatible environment classRandomLawyerAgent / GreedyLawyerAgent — Baseline agentsprompts.pytrain.pyGRPOTrainer