Skip to main content
Glama

Grade a decision against what happened after it

grade_decision
Read-only

Grades a recommendation-and-decision pair against before/after observation logs, returning holding, not-holding or refused so advisor systems can measure whether advice actually improved outcomes.

Instructions

Grades one recommendation-and-decision pair against a before/after observation log. Compares a pre-decision BASELINE window to a post-decision, exposure-aligned RESULT window on the same subjectId + checkKey, and returns 'holding' (the exposed post-decision window stayed under refuteThreshold bad observations AND its bad rate is lower than the baseline's), 'not-holding' (EITHER the exposed post-decision window hit refuteThreshold bad observations, OR its bad rate is not lower than the baseline's, even below that count -- 1 bad of 10 before, 1 bad of 3 exposed since is 'not-holding', and so is an exact tie such as 1 of 3 against 1 of 3), or 'refused' (the evidence didn't clear a floor -- see refusalCodes for exactly which one, never a vague 'unproven'). The rate comparison is exact -- it cross-multiplies the raw counts rather than comparing the rounded badRate fields or the sign of badRateDelta, so a not-holding can occur even when both windows display the same 3-place badRate. The refute bar is a fixed count, not a rate: 5 bad of 100 before and 2 of 500 since is 'not-holding' at the default threshold of 2, although the rate fell from 5% to 0.4%; for long windows, bound the window or raise refuteThreshold. Always show badRateDelta and the raw baseline/result counts next to the verdict, don't quote 'holding' on its own, and read verdict and refusalCodes rather than the prose sentence. The verdict grades the DECISION, not just whether advice was taken: a DISMISSED recommendation whose problem later surfaced also grades 'not-holding', because the evidence sided with the advice either way. Two things this tool refuses to let slide: (1) 'nothing has gone wrong since' only counts as a result if the baseline shows the problem existed before -- otherwise it's 'baseline_lacks_negative_signal'; (2) only observations where the advice could actually have applied (exposed === true) can create or reverse the headline verdict -- everything else is reported separately as secondary (whose own wouldBeVerdict can itself be 'refused'), labelled non-headline, and can never become the headline. Use this to close the loop on any recommender/advisor system that logs recommendations, human accept/reject calls, and later outcomes, instead of letting advice quality go unmeasured forever. For grading a whole population of engine-vs-human calls at once (rather than one decision against its own before/after window), use compute_divergence instead.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "decision": "<decision>",
      "recommendation": "<recommendation>",
      "observations": "<observations>"
    },
    "name": "grade_decision"
  }
}

Input Schema

NameRequiredDescriptionDefault
configNoFloors and thresholds, every field optional with a library default (see advice-ledger-kit's DEFAULT_GRADE_CONFIG). Omit entirely to use the library's defaults.
decisionYesThe human's call on the recommendation.
observationsYesEvery observation available. This tool does the filtering by subjectId + checkKey itself, so passing the whole ledger (observations for other subjects/checks too) is fine.
recommendationYesThe advice being graded.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.4.0
    • changedInput schema / properties / config / properties / refuteThreshold / description
      Previous value: -"How many bad exposed post-decision observations it takes to overturn the decision. Defaults to proposeThreshold (symmetric). Setting this BELOW proposeThreshold throws -- refuting more cheaply than you proposed is a thumb on the scale, not conservatism."New value: +"How many bad exposed post-decision observations it takes to overturn the decision (a fixed count, not a rate, however long the window). Defaults to proposeThreshold (symmetric). Setting this BELOW proposeThreshold throws -- refuting more cheaply than you proposed is a thumb on the scale, not conservatism."
    • changedInput schema / properties / decision / properties / decidedAt / description
      Previous value: -"ISO-8601 timestamp of the human's call. Observations strictly before this form the baseline window; observations strictly after (and exposed) form the result window; observations timestamped exactly at this instant are counted (`atBoundaryObservations`) but grade neither window. Must be non-empty."New value: +"When the human made the call: a calendar date 'YYYY-MM-DD' (read as UTC midnight) or a timestamp with seconds and an explicit zone ('2026-02-01T09:30:00Z' or '+hh:mm'), at most three fractional digits. Any other value (no zone, no seconds, an impossible date) is a tool error; nothing is guessed. Instants are compared, not text. Observations strictly before this form the baseline window; observations strictly after (and exposed) form the result window; observations timestamped exactly at this instant are counted (`atBoundaryObservations`) but grade neither window. Must be non-empty."
    • changedInput schema / properties / decision / properties / recommendationId / description
      Previous value: -"Must equal recommendation.id, or grading is refused with 'decision_recommendation_mismatch'."New value: +"Must equal recommendation.id, or grading is refused with 'decision_recommendation_mismatch'. A recommendationId that shows nothing (empty, whitespace or invisible characters only) is a tool error."
    • changedInput schema / properties / observations / items / properties / observedAt / description
      Previous value: -"ISO-8601 timestamp of this reading. Compared as a string against decidedAt -- use one consistent format. Must be non-empty."New value: +"When this reading was taken, in the same grammar as decidedAt: 'YYYY-MM-DD' (UTC midnight) or a timestamp with seconds and an explicit zone. Compared as an instant against decidedAt, so '2026-02-01T01:00:00+01:00' and '2026-02-01' are the same moment. An invalid value on a matching observation is a tool error."
    • changedInput schema / properties / recommendation / properties / checkKey / description
      Previous value: -"The thing later observations report on -- this is what makes a recommendation gradeable at all. An empty/whitespace-only checkKey is always refused ('no_gradeable_check_key'), since no observation could ever be matched back to it."New value: +"The thing later observations report on -- this is what makes a recommendation gradeable at all. A checkKey that shows nothing (empty, whitespace, or zero-width/bidi control characters only) is always refused ('no_gradeable_check_key'), since no observation could ever be matched back to it."
    • changedInput schema / properties / recommendation / properties / id / description
      Previous value: -"Stable identifier for this recommendation. `decision.recommendationId` must equal this exactly, or grading is refused."New value: +"Stable identifier for this recommendation. `decision.recommendationId` must equal this exactly, or grading is refused. An id that shows nothing (empty, whitespace or invisible characters only) is a tool error."
    • changedInput schema / properties / recommendation / properties / proposedAt / description
      Previous value: -"ISO-8601 timestamp the recommendation was proposed. Use one consistent format for every proposedAt/decidedAt/observedAt in a given ledger -- dates are compared as strings, and mixing 'YYYY-MM-DD' with a full timestamp compares wrongly."New value: +"When the recommendation was proposed. Recorded for your own ledger; grading does not read it. Use the same format as decidedAt/observedAt: a calendar date 'YYYY-MM-DD' (read as UTC midnight) or a timestamp with seconds and an explicit zone ('2026-02-01T09:30:00Z', '2026-02-01T10:30:00+01:00'), at most three fractional digits."
    • changedInput schema / properties / recommendation / properties / subjectId / description
      Previous value: -"What the advice is about: a project, a machine, a queue, an account."New value: +"What the advice is about: a project, a machine, a queue, an account. A subjectId that shows nothing (empty, whitespace or invisible characters only) is a tool error."
  2. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only declare read-only and closed-world; the description carries far more: it defines the three verdict strings with concrete edge cases (e.g., '1 bad of 10 before, 1 bad of 3 exposed since is not-holding'), explains the exact cross-multiplied rate comparison, warns that a fixed-count refute bar can override a falling rate, describes refusal behavior via refusalCodes, and clarifies that secondary/exposed observations can never become the headline verdict. This is unusually rich behavioral detail beyond 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.

Conciseness4/5

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

The description is front-loaded with the core action and verdict definitions before moving into caveats. It is dense and long, with some repeated emphasis on edge cases (ties, rounded badRate), but nearly every sentence carries actionable distinction rather than filler. A single dense block, though, makes it slightly harder to scan than a structured layout would.

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?

Given a complex nested-input tool with no output schema, the description defines return values (verdict, refusalCodes, badRateDelta, raw baseline/result counts, secondary wouldBeVerdict) and explains how those fields should be read. It also covers refusal semantics, threshold interactions, and exposure filtering, leaving little ambiguity for an agent to invoke and interpret the tool correctly.

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 schema already documents parameters thoroughly. The description still adds useful interpretation, notably that refuteThreshold is 'a fixed count, not a rate' and the concrete example that 5 bad of 100 before versus 2 of 500 since is not-holding, plus advice to bound windows or raise the threshold for long windows. This goes meaningfully beyond restating the schema fields.

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: 'Grades one recommendation-and-decision pair against a before/after observation log,' and immediately names the exact inputs (subjectId + checkKey, baseline vs. result windows). It also explicitly distinguishes itself from the sibling compute_divergence, which handles populations rather than one decision.

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?

It states the intended use case explicitly ('Use this to close the loop on any recommender/advisor system that logs recommendations, human accept/reject calls, and later outcomes') and names the alternative for whole-population grading ('use compute_divergence instead'). The guidance covers both when to use and when to defer to another tool.

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