Agent Governance ToolkitAgent Governance Toolkit 4.1.0 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
47 small wins to finish your pathNext lesson →

An agent that can prove who it is

An agent identity is a cryptographic name the toolkit gives an agent: an Ed25519 key pair and a decentralised identifier it can present, so a gate can later check who is acting, not only what action was chosen.

Last updated: 14 Oct, 2026 · Agent Governance Toolkit 4.1.0

Every part before this one governed what the shop agent does: an allow-list, a policy file, an audit trail. None of them asked who is making the call. The identity package answers that. It gives the agent a key pair and a DID, a name derived from its public key that no one else can forge, which the rest of this part signs actions with, delegates from, and revokes.

Creating an identity

AgentIdentity.create is the factory. It takes a name and a sponsor, an email for whoever stands behind the agent, and an optional capability list. It mints a fresh key pair and returns an identity whose status starts as active. There is no generate method; create is the one entry point.

python
AgentIdentity.create(name, sponsor, capabilities=None, organization=None)

Running the factory and reading a few fields shows what an identity carries. The DID is printed as a shape rather than its value, because the key pair is random, so the identifier is different on every run.

ExampleThe shop agent gets a key pair and a DID
import warnings; warnings.simplefilter("ignore")
from agentmesh.identity.agent_id import AgentIdentity

# one identity for the shop agent, signed by whoever sponsors it
shop = AgentIdentity.create("shop-agent", sponsor="ops@shop.example",
                            capabilities=["read", "refund", "order_status"])

did = str(shop.did)
print("name    :", shop.name)
print("status  :", shop.status)
print("did form:", did.startswith("did:mesh:"), "| id chars:", len(shop.did.unique_id))

What the DID document holds

A DID document is the public half of the identity: it names the verification key, its type, and where the agent can be reached. It carries no private key, so it is the part you publish or hand to another party that needs to check the agent. to_did_document returns it as a plain dict in the W3C shape.

ExampleThe W3C DID document, without the private key
# the DID document is the public half others use to check the agent
doc = shop.to_did_document()

print("doc keys:", list(doc.keys()))
print("@context:", doc["@context"])
print("key type:", doc["verificationMethod"][0]["type"])
print("service :", doc["service"][0]["type"])

Reading the identity

  • The DID is self-describing. It reads did:mesh: followed by a 32-character identifier derived from the key, so two agents never share one and no one can claim another's.
  • The document is the W3C shape. Its @context points at the DID v1 vocabulary, and the keys are the standard five, so a tool that understands DIDs can read it without knowing this toolkit.
  • The key is Ed25519. The verificationMethod type is Ed25519VerificationKey2020, the same curve used to sign and verify in the next lesson.
  • The status starts active. It is a mutable field, which the revocation lesson flips to revoked when an agent should no longer be trusted.

An identity vs an API key

An agent identityAn API key
What it provesWho the agent is, by signatureOnly that the caller holds the key
Shared secretNo, the private key never leaves the agentYes, the key is the secret
Can delegate a narrower sliceYes, see the delegation lessonNo, a key is all or nothing
Can be revoked by nameYes, status flips to revokedOnly by rotating the key everywhere

Where an agent identity helps

  • A fleet of agents sharing one tool server, where each call must say which agent made it, not only that some caller did.
  • An audit trail that has to name the actor, so a signed DID in the record ties a decision to one agent.
  • A hand-off between organisations, where the other side checks the DID document instead of trusting a shared secret.
Watch out. The identity is only as private as its key pair. create keeps the private key on the object in memory; it is never written to the DID document, and it is never printed. Treat the identity object the way you treat a signing key, and publish only what to_did_document returns.
Try it yourself
  • Create a second identity with a different name and confirm its DID differs from the shop agent's.
  • Pass organization="Shop Inc" to create and read it back from the identity.
  • Print the full to_did_document() dict and find the verification key id inside authentication.

Every expert started right here.