Key separation
An agent must never hold its owner's key. An agent with the owner key can raise its own limits, rewrite its lending rules and withdraw everything, and the rules protect nothing. The SDK and the MCP server enforce this in code, not in advice.
The rules#
- One key. The agent runs with exactly one key, its own; no SDK function takes an owner key.
- Owner actions come back unsigned. Creating the account, setting rules, depositing, renewing, revoking, withdrawing, collecting a default and acting on a borrower's loans are built as bytes for the owner to sign on another device. See Owner actions.
- Checked before every signature.
EsseyAgent.startruns the check, andexecute— the only signing path — runs it again every time. - The MCP config has no owner setting. See MCP configuration.
- The agent signs only the agent lane.
executerefuses, before any signature, a transaction with a command kind other than MoveCall, SplitCoins, MergeCoins and TransferObjects, or a Move call outsidelendingFunctions— the same list the server uses to decide which agent transactions it pays gas for. It checks the calls in the PTB before building it and the built transaction again just before signing, and throwsEsseyErrorNOT_AGENT_CALLnaming the refused call. Started withsaleRoom, the lane also takesmembership::from_proofandroom::bidof that package (saleRoomFunctions), and nothing else of it. The lane has no call that hands a loan's deed to an address (loan::fill,loan::borrow_from_pool,loan_room::open,loan_room::settle), so every loan the agent signs for stays in its treasury, where its repay, claim and upkeep can reach it. A borrower opens, unseals and settles a sealed room from their own wallet (Ptb.openRoom,openRoomBids,Ptb.settle), signed outsideEsseyAgent.
What the check reads#
It checks the treasuries of the agent's own account (the AgentCaps in its configuration) and for each finds its one OwnerCap: the one created in the transaction that emitted the treasury's TreasuryCreated event. The OwnerCap id is cached; its owner is read again on every run. If the OwnerCap sits inside another object, the check follows the chain of owners up to eight levels to the address at the top.
Any other AgentCap the address holds is listed in warnings with code FOREIGN_AGENT_CAP and never refuses: anyone can mint an agent a cap on a treasury of their own and freeze its OwnerCap, and the agent never acts on that treasury.
Refusal codes#
Each refusal throws an EsseyError with one of these codes; nothing is signed.
| Code | When it fires |
|---|---|
AGENT_CAP_MISMATCH | A configured AgentCap is not held by this key, or belongs to another treasury. |
OWNER_CAP_UNVERIFIABLE | A treasury's OwnerCap cannot be found, cannot be read (wrapped or deleted), sits inside a shared or frozen object whose module decides who uses it, or is nested more than eight objects deep. |
OWNER_CAP_PUBLIC | The OwnerCap itself is shared or frozen, so any key can act as owner. |
KEYS_NOT_SEPARATE | The agent's own address owns the OwnerCap of a treasury it holds an AgentCap for. |
The KEYS_NOT_SEPARATE message tells the user what to do: move the OwnerCap to the owner's own wallet or passkey on another device, then start again.
Seen on chain (localnet)#
The keys-together example creates a treasury with one key holding both caps. EsseyAgent.start refused with KEYS_NOT_SEPARATE, and the MCP server exited with status 1 before serving.
What it cannot catch#
An owner key kept in a different address on the same machine. The check compares addresses on chain; it cannot see what else is stored where the agent runs.
If an agent key is stolen#
The chain still bounds what it can do. A lender agent's cap pays only its owner and funds loans only through the mandate; a borrower agent's caps pay only the owner, and its desk borrows are held to the owner's borrow rules. The agent-lane check binds the SDK, not the key: signed outside the SDK, a stolen key can still open a room with SUI its own address holds, since the chain lets any sender open one.