Skip to main content
Glama

Solve outcome curves to hit a pipeline's targets

solve_outcome
Read-onlyIdempotent

Adjust outcome-curve lever values until SQL-computed metrics over generated tables hit per-period targets. Use it when metrics derive from generated data, not declared fields.

Instructions

Find outcome-curve values that make SQL metrics over the data hit targets.

Use it when the number that matters is computed from the generated tables rather than declared on them: net revenue after refunds, revenue after a fee, a ratio of two tables. Each query runs in DuckDB over the generated tables and returns two columns, the period and the value, one row per period. Each target names a metric, the table.column outcome curve that moves it (the lever, which must have exact per-period values), and the value per period. Set direction: "inverse" when a larger lever lowers the metric, as refunds lower net revenue.

Nothing is written. On success, replace each lever curve's curve_points in your schema with levers[lever], then generate as usual; attest_dataset will confirm the curves hold.

Args: schema: The schema dict, with an outcome curve per lever. queries: Metric name to DuckDB query, e.g. {"net": "SELECT date_trunc('month', ordered_at), SUM(amount) * 0.97 FROM orders GROUP BY 1"}. targets: [{"metric", "lever", "values": {"2025-01": 70000}, "direction"?}]. tolerance: Relative tolerance per period, e.g. "0.5%". max_iterations: Generate-and-query rounds allowed, at most 40. seed: Seed used for every round.

Returns: {"ok", "converged", "reason", "message", "iterations", "best_iteration", "levers", "steps"}. reason is one of converged, max_iterations, max_seconds, diverging, unresponsive, infeasible, pipeline_error; message says what to change when it is not converged.

Input Schema

NameRequiredDescriptionDefault
seedNo
schemaYes
queriesYes
targetsYes
toleranceNo1%
max_iterationsNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.8

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the readOnly/idempotent annotations: it discloses the DuckDB execution model, a 40-iteration cap, per-period tolerance semantics, inverse-lever behavior, the full reason-code set, and the exact success workflow including replacing curve_points before regeneration. The one redundant line ('Nothing is written') is consistent with annotations rather than contradictory.

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?

Front-loads purpose, then usage, then args and returns in a predictable structure. It is somewhat prose-heavy and repeats the annotation-backed 'Nothing is written', but nearly every sentence carries useful information.

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?

The tool is complex with nested objects and zero schema description coverage. The description compensates fully by covering inputs, execution behavior, convergence/failure reasons, and the downstream workflow; the output schema makes a deeper return-value explanation unnecessary, though the summary of keys is a bonus.

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

Parameters5/5

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

Schema coverage is 0%, so the description carries the full burden and does so: it explains schema, queries (with a worked DuckDB example), targets including metric/lever/values/direction, tolerance format ('0.5%'), the max 40 iterations, and seed reuse across rounds.

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?

States a specific verb and resource: find outcome-curve values so that SQL metrics over generated data hit targets. It explicitly distinguishes itself from declared-metric workflows and from siblings like attest_dataset, which only confirm results.

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?

Gives a clear when-to-use rule ('when the number that matters is computed from the generated tables rather than declared on them') with concrete examples, and names attest_dataset as the post-step. There is no explicit when-not-to-use section, but the alternative workflow is strongly implied.

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