Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

dml_diagnostics

Read-only

Build a diagnostic report from a DML causal result to verify overlap, unconfoundedness, and instrument validity, then identify violations and next steps before acting on estimates.

Instructions

Build a :class:DMLDiagnostics report from a DML CausalResult. Assumptions: Unconfoundedness (IRM/PLR) or instrument validity (IIVM/PLIV) given the covariates; Overlap / positivity; Neyman-orthogonal score plus cross-fitting; nuisance estimators converge fast enough (o(n^-1/4)). Pre-conditions: Covariates, treatment, and outcome with enough data for cross-fitted machine-learning nuisances; For instrumented variants (PLIV / IIVM): an instrument as well. Failure modes: Propensity scores near 0/1 -- overlap failure inflates variance and bias -> Trim extreme scores, restrict the estimand to the overlap region, or report sensitivity (dml_sensitivity). Alternatives: sp.tmle, sp.auto_cate, sp.causal_forest. Typical minimum N: 500.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clipNoFor IRM-style overlap: count units with propensity within ``[0, clip] [1-clip, 1]`` as overlap-violating.
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
resultYesResult returned by :func:`statspai.dml.dml`. Must include the post-fit residuals (``model_info['_y_resid']``, ``model_info['_d_resid']``); for IRM, additionally the propensity ``model_info['diagnostics']['pscore_min']`` etc. are surfaced.
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_pathNoAbsolute 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.
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.6/5.0
Behavior5/5

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

Beyond the readOnlyHint and openWorldHint annotations, the description discloses statistical assumptions (unconfoundedness, overlap, Neyman-orthogonal scores, cross-fitting, nuisance convergence rates) and failure modes (propensity near 0/1 inflates variance/bias). This adds substantial behavioral context about what the report validates and what can go wrong.

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 front-loaded with the core action and then organizes assumptions, preconditions, failure modes, alternatives, and sample-size guidance into clearly labeled segments. It is dense but each sentence contributes substantive context; no filler.

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 diagnostics tool with 8 parameters, an output schema, and complete schema coverage, the description covers the surrounding context well: assumptions, data requirements, failure handling, alternatives, and minimum sample size. Nothing essential for correct invocation is missing.

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?

Schema coverage is 100%, so the baseline is 3. The description adds real value by specifying what the 'result' parameter must contain (post-fit residuals, propensity diagnostics for IRM), which goes beyond the schema description. Other parameters are not individually enriched, but the schema already documents them adequately.

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 verb and resource: 'Build a DMLDiagnostics report from a DML CausalResult.' This clearly states what the tool does and what input it consumes, and it distinguishes itself by listing alternatives (sp.tmle, sp.auto_cate, sp.causal_forest). It is not a tautology because it adds the source object type and report deliverable.

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

Usage Guidelines4/5

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

The description provides concrete conditions for use: preconditions (covariates, treatment, outcome; instrument for PLIV/IIVM), failure-mode handling with a pointer to dml_sensitivity for overlap violations, and a 'Typical minimum N: 500' guideline. However, the three alternatives (sp.tmle, sp.auto_cate, sp.causal_forest) are named without explicit when-to-choose conditions, so guidance is clear but not exhaustive.

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