Ghulam Mustafa Zafar

System design7 min read

How capabilities are described, permissioned and versioned

Describe every outcome, check permission in exactly one place, and treat every version as a separate thing. The three questions every capability on a multi-tenant agent platform has to answer.

By Ghulam Mustafa Zafar

Cover: twelve-pointed stars and hexagons, a tile pattern generated for this post in the system design glaze.

In the last post I said that in a composable platform, capabilities are typed, permissioned services, and agents are configuration that composes them. That sentence is easy to write. It hides three questions every capability has to answer before an agent is allowed to call it:

  1. What is it? What does it take, what can come back, and what does it do to the world?
  2. Who may call it? A person, an agent acting for a person, an automation at 3am?
  3. Which version? When it changes, what happens to the agents already running on it?

This post is how I answer each one on a multi-tenant agent platform where internal teams ship capabilities and customers’ agents call them. The short version: describe every outcome, check permission in exactly one place, and treat every version as a separate thing.

Described: a contract that declares every outcome

Each extension ships a manifest. It names the extension, says how it connects to the outside system (one account, several, or none), lists the secrets it needs, and declares its tools and triggers. A tool has:

  • a name and a description, which the model reads;
  • an input schema and an output schema, both JSON Schema, both required;
  • a fixed list of error codes it may return;
  • a timeout.
# Illustrative only: an extension manifest with one tool.
extension: calendar
connection: one-account # one account, several, or none
secrets: [client_secret]
tools:
  - name: create_event
    description: Create an event in the connected calendar.
    timeout: 10s
    input:
      type: object
      required: [title, start, end]
      properties:
        title: { type: string }
        start: { type: string, format: date-time }
        end: { type: string, format: date-time }
        note_to_guests: { type: string, outgoing_text: true }
    output:
      type: object
      required: [event_id]
      properties:
        event_id: { type: string }
    errors: [not_found, conflict, rate_limited, reconnect_required]

The important word is every. A tool’s answer is always an envelope: either ok with output that matches the declared schema, or one of a short, fixed list of failures (not_found, conflict, rate_limited with a retry time, reconnect_required, and a few more), each with a human sentence. HTTP status codes are not part of the contract. Anything other than a well-formed envelope counts as a transport failure, which the platform reports as unavailable.

Why so strict? Because an agent is not the only caller. Automations call the same tools, and an automation has to branch on the result without a model in the loop. “500 Internal Server Error” tells it nothing, including the one thing it most needs to know: whether the side effect happened. A closed set of outcomes is something code can branch on and something a model can explain.

  1. SuccessokOutput matches the schema of the version called
  2. Declared failuresnot_foundconflictrate_limitedreconnect_requiredThese and a few more, each with a sentence a person can read. rate_limited also carries a retry time
  3. Anything elseunavailableA 500, a timeout or a malformed answer. The platform reports it as a transport failure
Every call ends in exactly one of these. Code can branch on the result, and a model can explain it.

The output schema is enforced, not just documented. The platform checks every result against the schema of the version that was actually called. Validation has three modes (off, observe, enforce) and the default is enforce, so a malformed result never reaches an agent. When a check fails, the log records the JSON path and the failed keyword, never the value, because results carry customer data.

The schema also carries a small amount of platform behaviour. An input property a person will read, such as an email body or a text message, is marked as outgoing text. Before the call leaves the platform, the guardrail checks every marked argument, and a blocked call never reaches the extension. The capability describes. The platform enforces. A tool can also declare a risk level, but that is for display only. Whether a call needs human approval is the platform’s and the tenant’s decision, never something a capability gets to say about itself.

Why not MCP as the contract?

MCP is a good way to author tools and a good protocol inside an extension. As the contract between a platform and its capabilities, it is the wrong shape for us. MCP tools do declare input and output schemas, and a server must honour them. But the tool list can change at runtime, and nothing versions or pins a tool, so an automation has no way to hold a server to the contract it was tested against. Deterministic automations need the opposite: a versioned manifest with frozen schemas. So the contract is an explicit manifest plus a small signed HTTP API, and anyone who likes MCP can use it behind that line.

Permissioned: one check, every surface

On the platform’s own admin plane, every capability is registered once, as an operation: typed input, typed output, a permission and an audit hook. The REST route the portal calls and the MCP tool an AI assistant calls are two front doors to the same operation. The permission is checked inside the operation itself, not only in the route, so a new front door cannot forget it. (Customer-facing operations follow the same shape, with the tenant’s own access rules checked at the customer app’s boundary.)

The operation also writes its audit entry and commits once, after the entry is recorded, so the change and its audit row land in the same transaction. “Best effort after commit” audit logging is how you end up with changes nobody can account for.

AI callers of the admin plane (an assistant or coding agent working for a member of staff) get extra gates, and the gates live in one dispatcher rather than in each tool, so no tool can forget one:

  • Some operations are human-only. An agent cannot approve a human-in-the-loop review, take over a live call, mint a token that can place real phone calls, set a secret, or delete a database. Each refusal carries a reason the agent can pass on.
  • Changes need write mode and an explicit confirm. Without confirm=true, a mutating call returns a preview of what it would do.
  • “Who did it” comes from the verified caller. Fields like “created by” are filled from the authenticated identity. If an agent tries to supply them as arguments, the call is refused.
  • Every call is bounded by a timeout and a cap on calls in flight.
Staff in the portalREST route
An AI assistant working for staffMCP tool

One dispatcher for AI callers

  • Some operations are human-only
  • Changes need write mode and confirm=true
  • “Who did it” comes from the verified caller
  • A timeout and a cap on calls in flight

One operation

  • Typed input and output
  • Permission check
  • Audit entry, committed with the change
Two front doors, one operation. The permission and the audit entry live in the operation, so a new door can't forget them.

When the platform calls an extension, the tenant is part of the signature. Each request is HMAC-signed over the timestamp, method, path, tenant, connection, request id and body, and the extension refuses any mismatch. An extension cannot be talked into acting for a different tenant by something in the body. Its data is partitioned by tenant, and the platform enforces the tenant on every call in and out.

Versioned: every version is a separate thing

This is where most platforms cut corners, and where the cuts hurt most.

  • A version is frozen at upload. Every upload is a new version with its own tools and triggers. Changing anything means uploading another version.
  • “Current” is a human decision. One version is current, and a person makes another one current with a button. Older versions keep running.
  • Agents pin versions. An agent version may use at most one version of each extension across everything it reaches: its own tools, its sub-agents, the code tools it calls, and the events it subscribes to. Deploying the agent is blocked unless every version it needs is ready.
  • Tenants see what they need. That is the current version, plus anything they have been granted, are connected to, or are required to use by an agent they subscribe to. Two versions can run side by side for different tenants.
  • Upgrades wait for the tenant. An agent upgrade that needs a newer extension version is blocked until the tenant has moved their connection, and the message says so in plain words.
  • Settings follow the upgrade. A tenant’s review rules and switched-off tools are remapped to the new version by name. Without this, a switch-off silently stops applying the day you upgrade. That bug is invisible until it is very visible.
  • You can’t delete what’s in use. Deleting a version is refused while anything references it: an agent version, a code tool, a connection or an access grant. The check runs under a row lock, so an attach and a delete can’t race.
Three versions of one extension, and what references each
v1v2v3
StatusOlder, still runningCurrent, chosen by a personUploaded, not current yet
Agents pinnedAgent AAgent BNone
Tenants connectedTenant XTenant YNone
Delete it?Refused while in useRefused while in useAllowed, nothing references it
Every version is a separate thing. Agents and tenants bind one explicitly, and a version that anything still references can't be deleted.

The contract itself is versioned the same way. Within a contract version, changes are additive only: new optional fields, headers, endpoints and error codes, and extensions ignore anything they don’t know. Anything breaking becomes the next contract, and the old one stays supported until someone explicitly retires it. A platform release never rebuilds or restarts an extension.

What it costs

None of this is free, and it isn’t right for everyone.

  • Upgrades are deliberate work. Someone re-attaches a new version’s tools to an agent. We chose not to automate that yet, on purpose.
  • More things are alive at once. Parallel versions mean more running revisions to monitor and more combinations to reason about.
  • Schemas have to be written properly. In enforce mode, a sloppy output schema breaks real calls. That is the point, but it costs time at the start.
  • The vocabulary needs ownership. A fixed list of error codes only helps while someone guards it.

If you have one team, one channel and one integration, this is overkill. If many tenants run agents and automations on capabilities built by different teams, it is the minimum.

The test, extended

Keep reading

The ship of Theseus and the legacy rewrite

If AI replaces every line of a legacy system, is it still the same system? A two-thousand-year-old puzzle about identity turns out to be a practical guide to modernisation.

Philosophy2 min read