Agent Harness Tutorial · End to end · Zoom level 1
Front door
Before the harness thinks about what Rohan said, it makes sure of who he is and whether this exact message was already handled. None of this uses the model.
Who is asking comes only from the token. The browser sends an Entra ID token with every message. The harness checks its signature, that it was issued for this app, and that it has not expired. Rohan's customer id (PH-1001) is read from the token. If the message itself says "I am PH-2002", nobody listens.
A message sent twice is handled once. The browser makes up a fresh id for each message and sends it again if it has to retry. The harness writes a row called PH-1001:<that id> into the ledger before doing anything. A second copy finds the row and gets the first answer back, or a 409 if the first is still running. See doing a write exactly once.
Someone else's conversation looks like no conversation. If Rohan sends a conversation id that belongs to another customer, he gets 404, not 403, so he cannot even learn that it exists.
Want every detail? The long version is in the Series: sign-in, the token, and who may do what.
Code view: input, process, output, the call stack, the classes
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
agent_harness/identity/entra.py:104Checking the token: signature, issuer, audience, expirydef verify_entra(
token: str,
*,
issuer: Issuer,
now: int | None = None,
role_scopes: RoleScopes | None = None,
holder_claim: str = CLAIM_CUSTOMER,
) -> Principal:
"""`identity.verify` for Entra's claims: the same signature check, issuer,
audience and expiry (`decode`), the session named by `uti`, and an app role
granting the scopes `role_scopes` gives it.
`holder_claim` is where the customer id is read from. Entra writes a
directory extension attribute as `extn.<name>` (claims-fnol-azure A2), not
`customer_id`, so the overlay names it, and the far end reads the same name."""
claims = decode(token, issuer=issuer, now=now, require=("uti",))
party = claims.get("azp")
return Principal(
subject=str(claims["sub"]),
customer_id=holder_of(claims.get(holder_claim)),
scopes=frozenset(entra_scopes(claims, role_scopes)),
session=str(claims["uti"]),
party=party if isinstance(party, str) else None,
token=token,
)Tech choices (what we chose, Azure and open-source options): L16 · Identity & authz