Skip to main content

Example flows

Example flows β€” loading the slides…

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.

FlowWhat it teachesStart with
Company discoveryResolve and validate public PAP capabilitiesA company domain
Agent identityVerify personal-agent metadata and signing policyAn agent.json URL
DelegationVouch for a delegated key, naming no User and no CompanyVerified metadata
Direct Sign-In boundaryKeep OAuth state and PKCE outside the modelThe scopes a task needs
Session JWTBind one Session JWT to one HTTP requestA protected key
Session transportRestart and redirect without leaking tokens or Session JWTsA Session and access token
Conversation messagesCreate and retry idempotent messages safelyA conversation endpoint
Conversation eventsLong poll, drain, recover, and de-duplicate ordered eventsA conversation and cursor
Session lifecycleStart a signed-out Session, and restart it when refusedA company issuer
Direct Sign-In lifecycleSign in after user consent, keep the tokens in the hostA browser callback
Browser SessionJoin the agent's browser to the same SessionA join code and a Session
Refresh tokensRefresh, rotate, narrow, expire, and revoke without exposing the tokenA sign-in
Mediated Sign-InProtected input to the token endpoint as an extension grant, then a one-time codeThe extension's fields
Conversation streamingStream over SSE, reconnect from Last-Event-ID, never act on deltasAn open conversation
Conversation controlSign in mid-conversation, go direct, hand off, and closeAn authorization event
OperationsApprove the exact revision, new terms, a lost answer sent againAn operation to approve
A user with a companyThe whole journey with Manzanita, both sides from the SDKA user's request
Two companiesLedgerly acts for Ada at Northwind, by compositionTwo PAP relationships

Some features are shown by a runnable Pydantic AI example alone, with the guide that explains them:

ExampleWhat it teachesGuide
Company APIsRead and propose through a company's OpenAPI API and its MCP server (an access token for its URL alone)APIs coverage
Company serviceBuild a company with personal_agent_protocol.company and use it end to endIntegrate a company
Sign-in displayWhat a page gets of a PapSignIn display, and what a model is toldDevice Sign-In
TelemetryOne allowlisted event per protocol stageTelemetry

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-jwt signs and verifies a real ES256 Session JWT in host code and demonstrates one-use replay rejection, keeping only boolean policy evidence.
  • session-lifecycle drives the real SessionClient against a deterministic local company. Each request gets a fresh Session JWT, and session_ended starts a new Session once. Only status and boolean evidence reach the agent or React state.
  • direct-sign-in-lifecycle drives the real DirectSignInClient through 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.