Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

mediate

Read-only

Decompose total treatment effect into natural direct and indirect effects using mediation analysis. Requires binary treatment, mediator, and outcome; supports bootstrap confidence intervals.

Instructions

Mediation analysis (Imai-Keele-Tingley 2010). Decomposes the total effect into natural direct effect (NDE) and natural indirect effect (NIE) via an interventional or sequential-ignorability identification strategy. Validation: certified parity evidence. Assumptions: Sequential ignorability: (Y(t,m), M(t)) perp T | X; Y(t,m) perp M | T, X; No post-treatment confounder of the mediator-outcome relationship (classical Imai-Keele-Tingley); SUTVA on both mediator and outcome. Pre-conditions: binary treatment 0/1; mediator is a post-treatment variable causally between treat and y; pre-treatment covariates capture confounding for T-Y, M-Y, T-M. Failure modes: NDE + NIE do not sum to total effect (difference vs product decomposition) -> Nonlinear / interactive mediator model -- use sp.mediate_interventional or four-way decomposition; Sensitivity to unobserved T-M / M-Y confounder unknown -> Always report sp.mediate_sensitivity (Imai-Keele-Yamamoto rho bound); Post-treatment confounder L suspected -> Use sp.four_way_decomposition (VanderWeele 2014) which handles L. Alternatives: sp.mediate_sensitivity, sp.mediate_interventional, sp.four_way_decomposition, sp.proximal. Typical minimum N: 500.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome
alphaNoSignificance level for confidence intervals and tests.
treatYesBinary treatment
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
n_bootNoBootstrap reps for NDE/NIE CIs
mediatorYesMediator variable
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://.
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.
covariatesNoPre-treatment confounders
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.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses statistical assumptions, failure modes, and a required companion sensitivity analysis. It also warns about assumption violations and provides a minimum sample size, adding substantial behavioral context without contradicting the annotations.

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

Conciseness5/5

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

The description is dense but well organized: purpose, assumptions, pre-conditions, failure modes, alternatives, and sample-size guidance. The core function is front-loaded in the first sentence, and each subsequent section supports correct invocation or routing to a sibling tool.

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

Completeness5/5

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

For a high-complexity causal mediation tool, the description is remarkably complete: it covers identification assumptions, pre-conditions, failure modes, alternatives, and a minimum N. The output schema already handles return-value details, so the description need not repeat them. An agent has enough context to select and call this tool appropriately.

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

Parameters4/5

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

The schema already covers all 12 parameters at 100% coverage, so the baseline is 3. The description adds meaning beyond the schema by clarifying that treatment must be binary 0/1, the mediator must be post-treatment and causally between treatment and outcome, and covariates must capture confounding for T-Y, M-Y, and T-M. This is useful extra context, though most parameter-level details are left to the schema.

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 states a specific verb and resource: 'Decomposes the total effect into natural direct effect (NDE) and natural indirect effect (NIE)' via a named identification strategy. It also distinguishes itself from siblings by explicitly listing alternatives such as sp.mediate_sensitivity, sp.mediate_interventional, sp.four_way_decomposition, and sp.proximal.

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 gives explicit pre-conditions (binary treatment, post-treatment mediator, pre-treatment covariates) and when-to-use alternatives for common failure modes. For example, it directs users to sp.four_way_decomposition when a post-treatment confounder is suspected and always recommends reporting sp.mediate_sensitivity.

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