When an AI agent displays an order total to a user, where does that number come from? The answer seems obvious—sum up line items, add taxes, subtract discounts. But in agentic commerce, the calculation path matters as much as the result. Businesses need to know agents aren't fabricating totals, and agents need to know which fields to trust.
PR #261 formalizes the totals contract: explicit definitions for what subtotal, total, and grand_total mean, how they relate to each other, and what validation rules apply.
The PR introduces several key changes to UCP's order schema:
Each totals field now has precise semantics:
subtotal: Sum of line item amounts before adjustments (taxes, discounts, shipping). This is the "list price" total.total: The amount due after all adjustments except promotions that apply at payment time.grand_total: The final amount to be collected, including all adjustments and payment-time promotions.The schema now documents how these fields relate:
subtotal + taxes - discounts + shipping + fees = total
total - payment_promotions = grand_total
This isn't just documentation—it enables validation. An agent can verify that the numbers are internally consistent before presenting them to users.
The PR clarifies which fields are required in different contexts:
grand_total is always required when presenting payment informationsubtotal is required when line items are presentThe contract is explicit about one thing: the business is authoritative. An agent may calculate expected totals for validation, but the displayed totals must come from the business response. This prevents price discrepancies from confusing users when agent math doesn't match backend logic.
The PR modifies several schema files to implement the formalized contract:
// Order totals with explicit semantics
message OrderTotals {
// Sum of line_items[].amount before adjustments
// REQUIRED when line_items present
Money subtotal = 1;
// Pre-payment total after taxes, discounts, shipping, fees
// subtotal + taxes - discounts + shipping + fees
Money total = 2;
// Final collection amount after payment-time adjustments
// REQUIRED for checkout
Money grand_total = 3;
// Optional breakdown for transparency
Money taxes = 10;
Money discounts = 11;
Money shipping = 12;
Money fees = 13;
}
The schema also adds validation annotations that tooling can use to verify consistency:
option (ucp.validation) = {
rule: "subtotal_consistency"
message: "subtotal must equal sum of line_items[].amount"
};
Agents should validate totals consistency when receiving order responses. If the math doesn't add up, that's a signal something is wrong—either a bug in the business implementation or a tampered response.
The formalized contract means businesses must be explicit about their pricing logic. If you have unusual fee structures or conditional discounts, they need to fit within this model. The schema is flexible enough to handle most cases, but edge cases may require documentation in the fees or discounts breakdown.
The explicit relationships enable automated verification. A compliance tool can now check that UCP responses are internally consistent without understanding business-specific pricing rules.
This PR lands alongside #267 (disclosure contracts) as part of a larger push to formalize UCP's core contracts before 1.0. Expect similar treatment for:
The protocol is moving from "flexible and loose" to "explicit and verifiable"—essential infrastructure for enterprise adoption where audit trails and compliance matter.