Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

optimal_match

Read-only

Performs optimal 1:1 matching via the Hungarian algorithm to minimize covariate imbalance between treated and control groups, enabling valid causal inference.

Instructions

Optimal 1:1 matching via the Hungarian algorithm. Validation: certified parity evidence. Do NOT use when: either arm has more than ~10,000 units -- the assignment problem is superquadratic (see cost); use sp.psm or sp.match (greedy nearest-neighbour) at that scale. Cost: Materialises the dense n_treated x n_control distance matrix, then solves a linear sum assignment (Hungarian, ~O(n^3) worst case). Both memory and time degrade sharply past a few thousand units per arm. 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 dif...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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
metricNometric parameter (str).mahalanobis
caliperNoDrop any pair with distance greater than ``caliper``.
outcomeYesOutcome variable column name or outcome array.
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.
treatmentYesTreatment indicator, treatment variable, or treatment array.
covariatesYesCovariate matrix, DataFrame, or column names.
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.7/5.0
Behavior5/5

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

Beyond the readOnlyHint=true annotation, the description discloses substantial behavioral traits: it materializes a dense n_treated x n_control distance matrix, uses an O(n^3) Hungarian solver, and warns that memory and time degrade sharply. It also lists assumptions, pre-conditions, and failure modes. This goes well beyond what annotations or the schema convey.

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 long but well-structured with labeled sections: validation, scale warning, cost, assumptions, pre-conditions, and failure modes. It is front-loaded with the core purpose. The 'Validation: certified parity evidence' line is cryptic, and the failure-modes section appears truncated, which prevents a perfect score.

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 computationally heavy matching tool, the description covers the essentials: scale limits, complexity, assumptions, pre-conditions, and failure-mode remedies. An output schema exists, so return-value documentation is not required here. However, the meaning of 'certified parity evidence' is unexplained, and the failure-modes list is cut off, leaving the guidance slightly incomplete.

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 description coverage is 100%, so the baseline is 3. The description adds meaning by specifying that covariates should be pre-treatment, that the treatment should be binary or low-cardinality, and that covariate overlap is required. This contextualizes the covariates and treatment parameters beyond the schema's terse descriptions, though it does not address every parameter in detail.

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 precise statement: 'Optimal 1:1 matching via the Hungarian algorithm.' This names the operation, the resource/units being matched, and the algorithm. It also distinguishes itself from sibling matching tools by explicitly naming sp.psm and sp.match as alternatives for larger samples, so an agent can tell it apart without opening the schema.

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 is explicit about when NOT to use it ('Do NOT use when: either arm has more than ~10,000 units'), names the alternative tools to use at that scale, and provides assumptions and pre-conditions that define appropriate use. This is strong, actionable guidance rather than vague context.

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