Agent / Tools from a state machine's transitions

When a tool is hidden, and when a call is refused

Before any input arrives, the guard is checked against the current state alone. The check answers true, false, or unknown. It is unknown when the part that decides it reads the input, as amount <= balance does, or calls a function metakit cannot look inside. Only false takes the tool away. A guard made of several parts is false when any one part is false, even if another is unknown: withdraw needs the account open and amount <= balance, so once the account is frozen the first part is false and the tool is hidden whatever the amount will be. Each adapter does what its protocol allows:

AdapterA tool whose guard is false
foldkit-agent-mcpLeft out of tools/list; the client is sent tools/list_changed when the Model changes
foldkit-agent-webmcpUnregistered from the page, and registered again when the state allows it
foldkit-agent-nativeStays registered, since the registry is fixed at start; a call answers ok: false
foldkit-agent-a2aStays on the agent card, tagged conditional; a call is refused

MCP and WebMCP have no way to show a tool as disabled, so those adapters hide it.

A tool whose guard is unknown stays offered. When it is called, the guard runs on the state and the decoded input together (a function metakit could not look inside is simply run), which always gives a plain yes or no. With 50 dollars in the account, withdraw with { "amount": 9000 } is refused with CapabilityUnavailableError, whose message is "withdraw" does not allow this input in the current state, and nothing is sent to update. The assistant reads that message as a failed tool call: over MCP, a tool result marked isError: true.

The state can also change after the assistant lists the tools and before it calls one. Each call checks the current state again before anything else. A withdraw sent after the account was frozen fails with Capability "withdraw" is not available right now, and does not run.

A call is checked in this order, and the first failure is the answer:

  1. Is the tool available in the current state?
  2. Does the input decode? An amount of 0, a string, or an extra field fails here as InvalidInputError.
  3. Is this caller allowed (authorize, below)?
  4. Does the guard allow this input in this state?

Step 1 is asked before authorize, and it also decides what the tool list shows, so a tool with no authorize tells every caller whether the state allows it. A tool you give authorize (below) skips step 1: it is always listed, and its whole guard is asked at step 4. A caller authorize refuses then sees the same list and gets the same AuthorizationError whether the account is open or frozen, and learns nothing about the account. A caller it allows, calling pay on a frozen account, is refused at step 4 with the message above.