Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

sbw

Read-only

Computes stable balancing weights to remove covariate imbalance between treatment and control arms, producing validated ATT/ATE/ATC estimates and diagnostic evidence for causal decisions.

Instructions

Stable Balancing Weights (Zubizarreta 2015) with optional ATT/ATE Validation: certified parity evidence. Assumptions: Unconfoundedness: treatment is as-good-as-random given the measured covariates; Overlap / common support: every unit has a non-degenerate probability of each treatment; The covariate set blocks all back-door paths. Pre-conditions: Pre-treatment covariates measured for treated and control units; A binary (or low-cardinality) treatment indicator; Sufficient covariate overlap between treatment arms. Failure modes: Poor overlap -- extreme propensity scores or few acceptable matches -> Trim or restrict to the common-support region and report the discarded units; Covariate imbalance remains after matching/weighting -> Re-specify the balancing model (CBPS, entropy balancing) and re-check standardized mean differences. Alternatives: sp.propensity_score, sp.cbps, sp.ebalance, sp.dml. Typical minimum N: 200.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yNoOutcome column. If provided, a weighted ATT/ATE estimate with HC-robust SE is attached to the returned :class:`SBWResult`.
alphaNoSignificance level for inference on the outcome.
deltaNoBalance tolerance. With ``tolerance_scale='sd'`` the constraint is ``|mean_T(X_j) - weighted mean_C(X_j)| <= delta_j * sd(X_j)``.
treatYesBinary 0/1 treatment indicator column.
detailNoPayload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip.agent
estimandNo``'att'`` reweights controls to match treated means (standard); ``'atc'`` reweights treated to match control means; ``'ate'`` reweights each group to match the pooled means.att
as_handleNoIf true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running.
data_pathYesAbsolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://.
objectiveNoDispersion objective. ``'variance'`` minimises Sigma w_i2; ``'entropy'`` minimises Sigma w_i log(n * w_i) (KL from uniform).variance
result_idNoOptional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns.
covariatesYesColumns whose means must be balanced.
data_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
data_sample_nNoOptional uniform random subsample size (seed=0, deterministic) — useful on huge panels.
solver_optionsNoPassed to ``scipy.optimize.minimize``.
include_squaresNoAlso balance second-moments (w_j2 columns).
tolerance_scaleNoStandard deviation ``delta`` is quoted in. ``'sd'`` is the full-sample sd; ``'target'`` the sd of the group being matched to and ``'group'`` the sd of the group being reweighted, matching ``sbw::sbw``'s ``bal_std="target"`` / ``"group"``; ``'raw'`` is unstandardised.sd

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, and the description aligns with that (no contradiction). The description adds valuable behavioral context beyond annotations: it discloses assumptions (unconfoundedness, overlap, back-door blocking), failure modes (poor overlap, covariate imbalance), and remediation steps. It doesn't detail output structure, but the output schema exists and the description mentions ATT/ATE validation and certified parity evidence, which is meaningful behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but well-organized: method identification, assumptions, pre-conditions, failure modes, alternatives, and sample size guidance. It front-loads the method name and purpose. It is longer than typical but every section earns its place for a complex causal-inference tool. Slight redundancy in assumptions (overlap stated twice) prevents a 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 16 parameters, an output schema, and rich sibling context, the description covers the key decision points: when to use, what to check, what to do on failure, and which alternatives exist. It doesn't explain the return value structure, but the output schema exists and the description mentions ATT/ATE validation. The typical minimum N guidance is a nice addition. Missing a bit on how to interpret 'certified parity evidence' but overall complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 16 parameters. The description adds context about the method's assumptions and failure modes but doesn't add parameter-level semantics beyond what the schema provides. Baseline 3 is appropriate since the schema carries the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific method name and citation ('Stable Balancing Weights (Zubizarreta 2015)'), states its purpose ('certified parity evidence'), and lists assumptions, pre-conditions, failure modes, and alternatives. It clearly distinguishes this from sibling tools like sp.propensity_score, sp.cbps, sp.ebalance, and sp.dml by naming them as alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly names alternatives (sp.propensity_score, sp.cbps, sp.ebalance, sp.dml) and provides failure-mode guidance ('Trim or restrict to the common-support region', 'Re-specify the balancing model'). It also states pre-conditions (pre-treatment covariates, binary treatment, sufficient overlap) and a typical minimum N of 200, giving an agent clear when-to-use and when-not-to-use signals.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools