H-06Action & ErgonomicsEngineering

Deterministic Envelopes & Schema Uniformity

Enforce uniform naming, pagination cursors, truncation markers and response envelopes across the entire tool surface.

Human UXAgent AXConsistency and standards→Uniform envelopes

Let's take a look at a clean, boring task. A revenue operations lead hands a CRM agent a Monday-morning job: find every contact at our 40 enterprise accounts who hasn't heard from us in 90 days, and enroll them in the Q1 win-back sequence. Three tools from the same CRM cover it: list_accounts, list_contacts and enroll_in_sequence.

The agent starts well. list_accounts(tier="enterprise") returns 25 accounts and a next_cursor. The agent passes the cursor back, gets the remaining 15, and sees next_cursor: null. Forty accounts, exactly as expected.

Then it calls list_contacts for each account. Northwind, the biggest, comes back with 25 contacts in a field called data and a small meta object at the bottom holding a page_token. There is no next_cursor anywhere. The agent has just learned what "more pages" looks like in this CRM, and this isn't it. It takes the 25 contacts as the whole account and moves on.

An hour later it reports: "Enrolled 312 dormant contacts across 40 accounts." The real number was closer to 740. Northwind alone has 212 contacts on nine pages, and the agent read one. The campaign launches to well under half of its list, and nobody finds out until the Northwind account executive asks why her dormant contacts never got the email.

No tool failed, and no response was wrong. Each tool described its own pagination accurately, in its own dialect. The failure lives in the gap between those dialects.

Why it happens

Now give the same job to a sales ops person in the CRM's web app. Every list screen ends in the same pagination bar: "1–25 of 212," with a Next button in the same corner. The design system draws it the same way on every page, so nobody has to think about it. Jakob Nielsen put this on his list of ten usability heuristics as consistency and standards: people should never have to wonder whether different words or layouts mean the same thing.

Agents get no pagination bar. They get keys in a JSON object, and they read those keys as instructions. The cues a tool sends through its names, parameters and types are what the Guide calls schema affordancesLexicon · 31Schema AffordancesUsage cues communicated through tool names, parameters and types.. next_cursor on the first tool told the agent, correctly, "there is more, and here is how to get it." On the second tool the same message was spelled meta.page_token, and the agent never matched it to the first.

That mistake is reasonable. Faced with a new tool, an agent does what any of us would do: it applies the rule it learned a minute ago on a sibling. A human ops person would hit the Northwind quirk once, grumble, and remember it for the next five years. The agent starts every session from zero, with nothing carried over but the prompt. The Guide calls this user the perpetual noviceLexicon · 09The Perpetual NoviceAn agent starting every session without accumulated interface familiarity.. For a perpetual novice, the only knowledge that reliably transfers between tools is the knowledge the tools themselves keep consistent.

Every inconsistency is a lesson the agent has to relearn, and a test it can fail silently.

The figure shows the three list tools in this CRM side by side. Start with the mixed version, where one rule learned on list_accounts is carried down through its siblings, then switch to the uniform envelope.

Rule learned on list_accounts: more pages if there is a top-level next_cursorlist_accountsnext_cursor: "c_25"40 of 40list_contactsmeta.page_token25 of 212list_activitiesno marker, capped at 100100 of 340Read in part, reported as complete. No error.

The rule misses on 2 of 3 tools, and the agent stops early with no error.

Fig. 6.1One rule, three dialects. The agent learns what 'more pages' looks like on the first tool and applies it to the rest. Where a sibling spells it differently, or not at all, the rule misses and the agent stops early with no error. A uniform envelope makes the same rule correct on every tool.

Notice that the rule never throws an error. It misses quietly. On list_contacts the marker exists but lives somewhere else. On list_activities there is no marker at all: the tool caps its array at 100 items, and a capped array looks exactly like a complete one.

Pagination is only the most expensive dialect. The same CRM names IDs id in one response and contactId in the next, while the enroll tool wants contact_ids. The agent copies the key it saw and gets a validation error. Each mismatch between what the agent means to do and the exact call the tool accepts widens the gulf of invocationLexicon · 29Gulf of InvocationFriction between an agent's intent and issuing a valid call., the distance from intent to a valid call. Here it costs one wasted turn. On a tool that silently ignores unknown parameters, it costs a write that did nothing.

What it costs

Silent partial work. This is the expensive one. An agent that stops at page 1 doesn't fail. It succeeds on a fraction of the data and reports the fraction as the whole. Reports undercount, migrations skip records, cleanup jobs leave most of the mess behind. A confident summary like "Enrolled 312" is the hardest kind of wrong to catch, because it looks finished.

Turns and tokens. Each dialect has to be learned, and learning costs calls: an error and a retry for contactId, a turn of reasoning about a strange meta block. Across 40 accounts and a dozen tools, those detours add up.

A tax on every session, forever. Tool descriptions can paper over the dialects ("note: this tool paginates with meta.page_token"). That works, and it has to be paid again in every session, by every agent, on every model. The Guide calls this recurring onboarding fee the teaching cost lawLexicon · 36The Teaching Cost LawRecurring per-session onboarding tax paid by any out-of-distribution tool.: any tool that departs from what the agent already expects charges a per-session tax to explain itself. A dozen tools with a dozen conventions means a dozen footnotes in the context window before the agent does any work.

Trust in the numbers. Once one campaign has gone out to half its list, someone has to check every count the agent reports. For a decision maker, that turns an automation into a reporting tool that needs a reviewer. The cheaper fix lives in the tool surface, not in the review process.

The fix

In plain words: every tool on the surface answers in the same shape, with the same names for the same things.

  1. One envelope. Every response has the same top-level keys in the same order: status, data, page, truncated. The keys are present whether the call found 0 items, 25 or an error.
  2. One pagination contract. Every list tool reports has_more and next_cursor inside page, and every list tool accepts that value back as cursor.
  3. One truncation marker. Anything the tool cut short says so, in the same field, with a way to get the rest.
  4. One name per thing. An entity's ID has one key everywhere it appears, in outputs and inputs alike: contact_id in list_contacts, contact_id on an activity, contact_ids on the enroll tool.

That is what deterministic means here: the shape of a response never depends on the result, or on which team wrote the tool.

Here is the Northwind call from the hook, before and after.

Beforelist_contacts → 43 tok
{
  "data": [
    { "contactId": "C-1182", "name": "Mia Lund", 1
      "lastActivity": 1758844800000 },
    … 24 more
  ],
  "meta": { "page_token": "eyJvZmZzZXQiOjI1fQ" } 2
}
  1. 1The ID is contactId here, id on accounts and contact_ids on the enroll tool. The timestamp is epoch milliseconds, while accounts use ISO dates. The agent has to translate every name it copies between tools.
  2. 2The only sign of more pages is a token nested in meta, under a name no sibling tool uses. An agent that learned next_cursor on list_accounts reads this as the last page.
Tokens43
Northwind contacts missed187 contacts
Afterlist_contacts → 69 tok
{
  "status": "ok",
  "data": [
    { "contact_id": "C-1182", "name": "Mia Lund", 1
      "last_activity_at": "2025-09-26T00:00:00Z" },
    … 24 more
  ],
  "page": {
    "returned": 25,
    "total": 212, 2
    "has_more": true,
    "next_cursor": "c_25" 3
  },
  "truncated": null 4
}
  1. 1contact_id is the same key the enroll tool accepts, and the timestamp uses the same ISO 8601 format as every other tool. The agent can pass values between tools without renaming anything.
  2. 2total: 212 turns "25 contacts" into "25 of 212." Even an agent that ignored the cursor would see that its count can't be the whole account.
  3. 3has_more and next_cursor sit in the same place, under the same names, on every list tool. The rule the agent learned on list_accounts now works here without any extra explanation.
  4. 4truncated is present even when nothing was cut, which costs a few tokens on every call. The constant key is the point: a missing marker can never be mistaken for "nothing was cut."
Tokens69
Northwind contacts missed0 contacts
Illustrative example

Walk through the pins in order. Pin 1 is about names. Renaming contactId to contact_id looks cosmetic, but the agent is a copier: it moves values from one tool's output into another tool's input. When both sides use the same key, the copy is correct by construction.

Pins 2 and 3 carry the main fix. has_more is an explicit yes or no, so an agent never has to infer "done" from a key it didn't find. total adds a second check: if the count and the total disagree, the agent knows to keep reading. Not every backend can count cheaply. When yours can't, leave out total or report an estimate, but never leave out has_more.

Pin 4 covers data cut short inside one response: a list capped at 100, a call note clipped to 500 characters. When something was cut, the field says what and how to get the rest, for example "truncated": { "field": "data", "omitted": 240, "full": "list_activities(contact_id=\"C-1182\", cursor=\"c_100\")" }.

About 26 extra tokens buy back 187 missing contacts from one account. They also remove the pagination footnote from the tool description.

Pick conventions the model already knows

When you choose the single convention, don't invent one. Models have read a great many public APIs, and some shapes are already familiar: snake_case keys, next_cursor, has_more, ISO 8601 timestamps, <entity>_id. How fluently a model knows a convention from its training data is its interface priorLexicon · 35Interface PriorHow fluently a model already knows an interface from pretraining.. A convention with a strong prior is guessed correctly before the agent reads a word of documentation. H-05 Align with Interface Priors covers how to choose them. This heuristic adds one demand: once chosen, use them everywhere.

One convention per concern

Tool surfaces drift into dialects one team at a time. These concerns drift most:

ConcernDialects found on one surfaceOne convention
More pagesnext_cursor, meta.page_token, nextPageToken, offset + limit, nothingpage.has_more and page.next_cursor; input cursor
Cut-off dataa silent cap, a trailing …, partial: truetruncated: null, or what was cut and how to get the rest
IDsid, contactId, ContactID, contact<entity>_id in every output and every input
OutcomeHTTP code only, ok: true, success: 1, an error stringstatus: "ok" or "error", same envelope either way
Timeepoch milliseconds, local time, "3 days ago"ISO 8601 in UTC

A shared response type and a lint rule in CI enforce this better than any style guide. The cheapest moment to fix a dialect is before the second tool copies it.

In MCP terms

MCP already wraps every tool result in one fixed outer shape: content, plus an optional structuredContent and isError. That shape stops where your data begins, so keeping status, data, page and truncated uniform across every tool is still your job.

  • Output schema (outputSchema). Declare the envelope once and attach the same schema to every list tool. Servers must return structured results that conform to it, and clients should validate them, so a tool that drifts back to meta.page_token breaks a check instead of shipping.
  • Structured content (structuredContent). Return the envelope here. The spec says a tool that does this should also put the serialized JSON in a text block in content, for backward compatibility.
  • Errors (isError). A failed call still comes back as a result, with isError: true. Keep the envelope on it, with status: "error".
  • Pagination (cursor, nextCursor). The protocol pages its own lists, such as tools/list, with opaque cursors and a page size the server chooses. Only a missing nextCursor means the end. Give your next_cursor the same rules.
  • Not in the protocol. Tool results have no built-in pagination and no truncation flag. page and truncated live in your payload, under the same keys on every tool.

Here is the part of the shared schema that makes "more pages" impossible to leave out:

"outputSchema": {
  "type": "object",
  "required": ["status", "data", "page", "truncated"],
  "properties": {
    "status": { "enum": ["ok", "error"] },
    "page": { "type": "object", "required": ["has_more", "next_cursor"] }
  }
}

A list_contacts response without has_more now fails validation, before an agent can read its silence as "done."

Spot it in your traces

Here is the session from the hook as it would appear in a trace log. Turn 3 is the turn that cost the campaign. Turn 4 is the one place the agent could have noticed.

TraceA CRM agent building a win-back list
  1. T1
    list_accounts(tier="enterprise")→ { "items": [25 accounts], "next_cursor": "c_25" }There is a next_cursor, so there are more accounts. Follow it.The agent pages correctly. It has also just learned this CRM's pagination rule, from one tool.
  2. T2
    list_accounts(tier="enterprise", cursor="c_25")→ { "items": [15 accounts], "next_cursor": null }40 accounts in total. Now list contacts for each.
  3. T3
    list_contacts(accountId="A-204")→ { "data": [25 contacts], "meta": { "page_token": "eyJv…" } }No next_cursor, so these are all of Northwind's contacts.The sibling tool spells "more pages" differently. The agent's rule misses, and it stops at page 1 of 9.
  4. T4
    list_contacts(accountId="A-311") … 38 more calls→ each returns at most 25 contacts31 accounts have exactly 25 contacts. Moving on.The same round number on most accounts is the classic sign of a page limit. Nothing in the responses asks the agent to look twice.
  5. T5
    enroll_in_sequence(sequence="q1-winback", contactId=[…])→ { "error": "unknown parameter contactId" }The ID is named three ways across three tools. The agent copied the one it saw last and lost a turn.
  6. T6
    enroll_in_sequence(sequence="q1-winback", contact_ids=[312 ids])→ { "enrolled": 312 }Done. 312 dormant contacts enrolled.A complete-sounding report built on partial reads. The real list was about 740.

To find the same failure in your own logs, look for these signals:

  • Counts that equal the page size. Find list calls that returned exactly 10, 25, 50 or 100 items and were not followed by another call to the same tool. Each one is a likely early stop.
  • Pagination tokens that were never used. Search responses for cursor, token, next and offset. For each value, check whether any later call passed it back. A token that never returns is a page the agent never read.
  • Errors on spelling variants. Validation errors that name a parameter the tool almost accepts (contactId for contact_ids, accountID for account_id) point straight at a naming dialect.
  • Reasoning that infers "done" from a missing key. Search the agent's reasoning for "no next", "no more pages", "that's all" and "these are all". Then check whether the tool actually paginates.
  • An inventory of your own envelopes. Dump one sample response per tool and list the top-level keys. If the same concern (more pages, IDs, errors, time) is spelled two ways, you have a dialect, whether or not a trace has caught it yet.

Review checklist

Run these across the whole tool surface, not one tool at a time: uniformity is a property of the set. The list pastes into a pull request template for any new tool.

Review checklist · 7 items
  1. Give every tool the same response envelope: the same top-level keys, in the same order, for success, empty results and errors.How to check Call three different tools once each, including one call that fails. Compare the top-level key sets; they should be identical.
  2. Use one pagination contract on every list tool: page.has_more, page.next_cursor, and an input parameter named cursor.How to check On each list tool, request a page smaller than the data set, then pass next_cursor back as cursor until has_more is false. Every tool should work with the same loop and no tool-specific code.
  3. Always state whether more data exists. Never let a missing key mean "done."How to check Query a list tool where the result exactly fills one page. The response must say has_more: false (or true) explicitly.
  4. Mark every truncation in the same field, saying what was cut and how to get the rest.How to check Request a record with a field longer than the tool's limit, and a list longer than its cap. Both responses should carry a non-null truncated value with a follow-up call.
  5. Give each entity one ID key everywhere, in outputs and inputs.How to check Search all tool schemas for the entity name (contact, account). Every ID key should match <entity>_id or <entity>_ids, with no camelCase or bare id variants.
  6. Use one casing convention and one timestamp format across all tools.How to check Run a lint over every input and output schema that flags camelCase keys and non-ISO 8601 date values. It should report zero findings.
  7. Enforce the envelope in code, not in a style guide.How to check Look for a shared response type or wrapper that every tool returns through. Adding a tool that skips it should fail a test or a CI check.

When laws collide

A uniform envelope adds structure to every call. That pulls against laws that want each response lean or familiar, and it reinforces the laws that need a predictable place to put information.

  • Where they clash
    Token Hygiene wants every token to help the next decision. A fixed envelope puts status, page and truncated on every response, including a tiny lookup that returns one record and will never paginate.
    How to have both
    Keep the envelope small and constant, around 20 tokens, and spend the savings elsewhere. Omit optional content inside data, never the envelope keys. A key that is always present can be skipped by the reader; a key that is sometimes present has to be checked for on every call.
  • Pulls against · H-05Align with Interface Priors
    Where they clash
    Some outputs are already in a format the model knows deeply: a unified diff, git log, CSV, SQL rows. Rewriting them into custom JSON fields to fit the envelope throws away a strong prior.
    How to have both
    Wrap, don't rewrite. The envelope carries status, page and truncated; the familiar format travels untouched as a string inside data. The agent gets a uniform frame around content it already knows how to read.
  • How they combine
    Affirmative Null Observations asks empty results to state their scope and count. A uniform envelope gives those statements a fixed home: the same status, page and count fields whether the result is empty, full or partial.
    What you get
    Zero results, one page of many and a truncated list all look alike in shape and differ only in values. The agent reads one structure and never has to treat empty, partial or complete as special cases.

Model size changes how the failure shows up. A larger model is more likely to notice that 31 accounts returned exactly 25 contacts and go back to check, at the cost of extra turns. A smaller model is more likely to trust the rule it learned and stop. A uniform envelope helps both, because it removes the need to notice anything at all.

Terms from this page

31Schema Affordances
Usage cues communicated through tool names, parameters and types.
09The Perpetual Novice
An agent starting every session without accumulated interface familiarity.
29Gulf of Invocation
Friction between an agent's intent and issuing a valid call.
36The Teaching Cost Law
Recurring per-session onboarding tax paid by any out-of-distribution tool.
35Interface Prior
How fluently a model already knows an interface from pretraining.
esc

Try “tokens”, “errors”, “stale”, “handoff” or “blast radius”.