Example flows
Start with the four cases, stories told in a reader's words and played on datalayer.ai: A Person and a Company, A Change, Approved Once, Your Application, a Company and Two Companies Together.
The pages below explain the protocol behavior demonstrated by the runnable Python and Agent Runtimes examples. Each flow shows where data travels, which Reactor capability owns sensitive work, and what may safely cross into model context.
| Flow | What it teaches | Start with |
|---|---|---|
| Company discovery | Resolve and validate public PAP capabilities | A company domain |
| Agent identity | Verify personal-agent metadata and signing policy | An agent.json URL |
| Delegation | Vouch for a delegated key, naming no User and no Company | Verified metadata |
| Direct Sign-In boundary | Keep OAuth state and PKCE outside the model | The scopes a task needs |
| Session JWT | Bind one Session JWT to one HTTP request | A protected key |
| Session transport | Restart and redirect without leaking tokens or Session JWTs | A Session and access token |
| Conversation messages | Create and retry idempotent messages safely | A conversation endpoint |
| Conversation events | Long poll, drain, recover, and de-duplicate ordered events | A conversation and cursor |
| Session lifecycle | Start a signed-out Session, and restart it when refused | A company issuer |
| Direct Sign-In lifecycle | Sign in after user consent, keep the tokens in the host | A browser callback |
| Browser Session | Join the agent's browser to the same Session | A join code and a Session |
| Refresh tokens | Refresh, rotate, narrow, expire, and revoke without exposing the token | A sign-in |
| Mediated Sign-In | Protected input to the token endpoint as an extension grant, then a one-time code | The extension's fields |
| Conversation streaming | Stream over SSE, reconnect from Last-Event-ID, never act on deltas | An open conversation |
| Conversation control | Sign in mid-conversation, go direct, hand off, and close | An authorization event |
| Operations | Approve the exact revision, new terms, a lost answer sent again | An operation to approve |
| A user with a company | The whole journey with Manzanita, both sides from the SDK | A user's request |
| Two companies | Ledgerly acts for Ada at Northwind, by composition | Two PAP relationships |
Some features are shown by a runnable Pydantic AI example alone, with the guide that explains them:
| Example | What it teaches | Guide |
|---|---|---|
| Company APIs | Read and propose through a company's OpenAPI API and its MCP server (an access token for its URL alone) | APIs coverage |
| Company service | Build a company with personal_agent_protocol.company and use it end to end | Integrate a company |
| Sign-in display | What a page gets of a PapSignIn display, and what a model is told | Device Sign-In |
| Telemetry | One allowlisted event per protocol stage | Telemetry |
The examples use deterministic or local transports where needed, so they can
teach the boundary without real credentials. The newer flows run against the
reference company in personal_agent_protocol.demo: real keys and real HTTP
over ASGI in one process, with no network. The two journeys at the end of the
table combine several features; each other page showcases one. Production hosts replace those
fixtures through Reactor contributions for egress, state, browsers, signing,
delegated key custody, and token storage.
Two implementations, one boundaryβ
The PAP repository contains plain Pydantic AI examples. Agent Runtimes contains
matching Loop applications and interactive Reactor views, one per flow, at
examples/personal-agent-protocol.
The protocol and secret-handling rules are the same in both.
What reaches the modelβ
Agent Runtimes depends on PAP in both Python and TypeScript. Its
PapPersonalAgentCapability uses DiscoveryClient and AgentIdentityClient
(and their TypeScript counterparts) to return aligned public summaries. For
company discovery the tool validates the document and supported protocol
version, follows verified OAuth metadata, and binds the issuer to the requested
company domain. Its result contains only:
- the verified organization and domain;
- the PAP version and issuer;
- advertised sign-in methods and interfaces; and
- extension names.
Raw response bodies, authorization URLs, callback parameters, assertions, Session JWTs, access tokens, and refresh tokens never enter model context.
What the Loop applications showβ
session-jwtsigns and verifies a real ES256 Session JWT in host code and demonstrates one-use replay rejection, keeping only boolean policy evidence.session-lifecycledrives the realSessionClientagainst a deterministic local company. Each request gets a fresh Session JWT, andsession_endedstarts a new Session once. Only status and boolean evidence reach the agent or React state.direct-sign-in-lifecycledrives the realDirectSignInClientthrough both sides of the browser pause: atomic state consumption, exact callback validation, partial consent, and token custody. Browser and credential material stays with Reactor contributions and the host transport.- PAP Guided Journey, a separate gallery example, advances the user, company, and wire views together across discovery, a signed-out conversation, Direct Sign-In, the company's offer, and an exact user-authorized result. The TypeScript SDK validates its fixtures at runtime, and the inspector shows host-only placeholders for every generated credential.
Run an Agent Runtimes exampleβ
From the Agent Runtimes repository root:
python -m pip install -e .
loop apps run examples/personal-agent-protocol/company-discovery/app.py
To validate the application definitions without starting an agent runtime:
python scripts/validate_pap_examples.py
Ask the company-discovery application to inspect a domain that publishes
/.well-known/poppy.json. The SDK applies HTTPS, public-network,
response-size, redirect, schema, version, domain, and issuer checks. Production
services must also pin the approved DNS result to the connection or route
requests through an enforcing egress proxy.
In Datalayer Studioβ
The metadata examples perform discovery in process to keep the integration readable. In Datalayer Studio, the agent tool calls the same typed Agent Runtimes capability, backed by a metadata gateway with opaque tenant and application context. That gateway owns DNS pinning, egress policy, caching, rate limits, observability, and audit, and returns the same credential-free summary.
Direct Sign-In is a separate authorization-gateway workflow. Studio starts it through a trusted Preview browser handoff, keeps PKCE and one-use state in host storage, and returns only status or an opaque connection reference to the application. Browser callbacks, Session JWTs, credentials, and tokens are never agent tool arguments or results.