Causal Decision Agent
# Causal Decision Agent
[](https://github.com/your-username/causal-decision-agent/actions)
[](https://www.python.org/)
[](LICENSE)
[](https://github.com/psf/black)
An AI decision-analysis agent that takes a business question, connects it to experiment and metric data, investigates using statistical tools, and produces an evidence-backed **decision** (`rollout | hold | investigate`) with a reproducible audit trace.
---
## šļø Project Architecture & Layout
```
CausalAI/
āāā src/
ā āāā stat_runtime/ # Pure statistical execution engine (Numbers only, no verdicts)
ā ā āāā data/
ā ā ā āāā schema.py # Data profiles & column metadata
ā ā ā āāā profiling.py # Data-type detection & variable association profiling
ā ā āāā experiment/
ā ā ā āāā srm.py # Sample Ratio Mismatch (SRM) Chi-Square test
ā ā ā āāā balance.py # Standardized Mean Difference (SMD) covariate balance
ā ā ā āāā ab_test.py # Welch's t-test A/B estimation with robust CIs
ā ā ā āāā cuped.py # Pre-experiment variance reduction (CUPED)
ā ā āāā causal/
ā ā ā āāā did.py # Difference-in-Differences (DiD) regression
ā ā ā āāā dml.py # Double Machine Learning (Chernozhukov et al.)
ā ā ā āāā refutation.py # Placebo treatment & bootstrap stability refuters
ā ā āāā metrics/
ā ā ā āāā definitions.py # Aggregations, windows, and guardrail definitions
ā ā āāā provenance/
ā ā āāā artifact.py # Reproducible execution & audit trace capture
ā ā
ā āāā causal_agent/ # Agent logic, decision layer, and protocol interfaces
ā āāā data/
ā ā āāā base.py # DataSource abstract interface
ā ā āāā duckdb_source.py # DuckDB canonical schema implementation
ā āāā evidence/
ā ā āāā state.py # EvidenceState (findings, warnings, unresolved, estimates)
ā āāā decision/
ā ā āāā engine.py # DecisionEngine (rollout | hold | investigate + guardrail priority)
ā āāā planner/
ā ā āāā base.py # AnalysisPlan & AnalysisPlanner interface
ā ā āāā deterministic.py # Rule-based planner batching runtime calls
ā āāā eval/
ā ā āāā synthetic_data.py # Canonical benchmark scenarios generator (10 scenarios)
ā ā āāā harness.py # Scoring harness (minimizes false-positive rollouts)
ā āāā server/
ā āāā mcp_server.py # Business-level MCP server interface
ā
āāā tests/
ā āāā unit/ # Fast unit tests for statistical routines & engine
ā āāā eval/ # Benchmark evaluation suite
ā āāā conftest.py # Pytest fixtures
ā
āāā plan.md # Master system design & engineering plan
āāā pyproject.toml # Package configuration & test runners
āāā requirements.txt # Core production dependencies
āāā requirements-dev.txt # Testing & linting dependencies
āāā .gitignore # Ignore files for Python, DuckDB, and IDEs
```
---
## ā” Core Invariants & Principles
1. **LLM never computes statistics**: All numerical computations occur inside `stat_runtime`.
2. **Tools return measurements, not verdicts**: Structured JSON with numbers, p-values, and bounds.
3. **Guardrails take precedence**: A statistically significant regression on a guardrail forces `HOLD` regardless of primary metric lift.
4. **False-Positive Rollout Minimization**: The harness explicitly optimizes for 0% false-positive rollouts on corrupted, underpowered, or mismatched experiments.
---
## š Getting Started
### 1. Activate Environment
```powershell
.\.venv\Scripts\Activate.ps1
```
### 2. Run Tests
```powershell
.\.venv\Scripts\pytest
```
### 3. Run Benchmark Harness
```powershell
.\.venv\Scripts\python -m pytest tests/eval/test_eval_scenarios.py -s
```
---
## š¤ Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines, testing instructions, and pull request workflow.
Please also review our [Code of Conduct](CODE_OF_CONDUCT.md).
---
## š License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
TDQS
Scored across 548 tools
Hundreds of tools are exact or near-exact duplicates: bjs is the same estimator as borusyak_jaravel_spiess and did_imputation; gardner_did duplicates did_2stage; frontdoor duplicates front_door; rosenbaum_bounds and rosenbaum_gamma share identical descriptions; postestimation_contract and postestimation_report are identical; and there are dozens of R-style or article-facing aliases (synthdid_estimate, sc_estimate, did_estimate, xlearner, psm). An agent cannot reliably distinguish the intended tool among so many overlapping aliases and variants.
Names are mostly snake_case, but the convention is inconsistent: some are concise verbs (did, regress, test, contrast), some are bare nouns (bridge, panel, rate), some are R-package aliases (synthdid_estimate, did_estimate), and some use different spellings of the same concept (frontdoor vs front_door, psm vs psmatch2 vs match). Abbreviated and opaque names like discos, megamma, sqreg, and rlassologit_effects break any predictable verb_noun pattern.
548 tools is an extreme mismatch for any server purpose, far beyond even the 50+ upper bound. The surface is a sprawling econometrics library rather than a curated decision-agent toolset, and an agent would face a prohibitive selection problem before doing any actual analysis.
For the causal-inference domain, coverage is effectively exhaustive: DiD (2x2, staggered, continuous, DDD, event studies), RD (sharp/fuzzy/multi-cutoff/bunching), IV (k-class, weak-instrument, shift-share, MR), synthetic control variants, matching and weighting, mediation, decompositions, sensitivity analysis, survival, time series, CATE/meta-learners, causal discovery, and offline policy learning are all represented. There are no obvious methodological gaps; the problem is surplus, not scarcity.