Build a personal agent
This guide separates the working SDK surface from the remaining roadmap.
Available now: discover and validate a company​
- Accept a company domain—not an arbitrary metadata URL—from the task.
- Call the discovery client.
- Choose only an interface and extension your runtime supports.
- Keep the returned identifier and endpoints attached to that verified company.
from personal_agent_protocol import DiscoveryClient
async with DiscoveryClient() as client:
company = await client.discover("example.com")
print(company.document.organization.name)
print(company.oauth_metadata.token_endpoint)
Do not send credentials during discovery. Python rejects private, loopback, link-local, and otherwise non-public resolved addresses by default. Server-side TypeScript callers should contribute a DNS-aware URL safety policy.
poppy.json needs at least one of agent, apis and web (§3.1). When the
company gives an organization.logo_uri, show the logo next to its
organization.name and domain, never in place of the domain, and serve your
own copy rather than having the user's device load it from the company; the
device sign-in start carries it as organization_logo (organizationLogo).
The company's name is unconfirmed​
Discovery proves which domain publishes a poppy.json, not that the domain belongs
to the company in organization.name (the 1.0 draft, §10.3). Any domain can claim
any name and logo, so a lookalike such as example-orders.example passes the same
checks as example.com: the domain is the company's identity, and the name is what
the domain says about itself. Choosing the right domain for the user is your
agent's job. When you show a company's name, help the user understand that nothing
has confirmed it, and show the domain with it whenever you are not sure the domain
is the one the user means (guides, Finding a company).
The SDK does this wherever it shows a name itself: Organization.label
(organizationLabel(organization)) gives Manzanita (manzanita.example), or the
domain alone when the name is the domain; a device or mediated sign-in display
(PapSignIn) names the company as name and domain; the pap CLI prints both on
every company line, approval and protected prompt. PapConfirm and PapReplies
show the company string you give them: pass the domain, or Organization.label,
never the name alone.
Versions​
A company can serve several protocol versions (§3.4). poppy.json is the
document of the version it prefers; supported_versions maps each other version
to that version's document. Discovery chooses the newest version compatible with
one the agent implements (before 1.0 the same major.minor) and, when it is not
poppy.json's own, fetches that version's
document: an HTTPS URL on the host that served poppy.json, no redirect
followed, with the version it is listed under, no supported_versions of its
own, and the company's domain and issuer; anything else is refused
(version_document_host, version_document_redirect,
version_document_mismatch), and a company with no compatible version at all is
unsupported_protocol_version. company.document is the chosen version's
document and company.protocol_version (companyProtocolVersion(company)) names
it.
The versions the agent implements are DEFAULT_PROTOCOL_VERSION, 1.0 as published
(DRAFT_PROTOCOL_VERSION, 1.0, named while it was the draft), unless you ask for others. 0.4 as published
(PROTOCOL_PROFILE) is opt-in: DiscoveryClient(protocol_versions=("1.0", "0.4"))
(discoverCompany(domain, { protocolVersions: ["1.0", "0.4"] })) uses a company at
1.0 when it serves it and at 0.4 otherwise; ("0.4",) alone uses only companies that
serve 0.4. Where 1.0 changes a rule, the SDK follows it at 1.0 and 0.4's at 0.4: a 1.0
document must describe each conversation protocol, a domain may name a port only at 1.0
(and only with allow_ports=True, allowPorts, which uses a company on another port
for testing), and a 0.4 Session never sends a null context field.
SessionClient.start(..., company=company) names the version the company was
discovered at (company.session_version, companySessionVersion(company)) in the
Session, or pass protocol_version (protocolVersion) yourself.
Every request with the Session header carries Poppy-Version, the version the
Session uses the company at (PapSession.protocol_version, protocolVersion),
the same for the Session's life. A company that does not serve it answers
version_unsupported (HTTP 400): the transport returns the refusal as it is
(version_unsupported(response)), and the host reads poppy.json again with
discover(domain, fresh=True) (discoverCompany(domain, { fresh: true })) and
chooses again. Choosing another version means a new Session and the request
again, once; choosing the same version, or none, ends the request. A
Deprecation or Sunset header on a response is a sign to move that company to a
newer version before the date it gives.
Extensions are declared the same way (§3.3, §3.4): a company lists each with an
entry per version it supports, negotiate_extensions(company.document.extensions)
(negotiateExtensions) picks the version this SDK implements for each one the
company lists, and SessionClient.start(..., company=company) keeps the result as
the Session's extensions, sent in Poppy-Extensions on every request with the
Session header, the same for the Session's life. A host that implements fewer
passes extensions itself. Nothing of the extensions is in the client metadata
any more, and the company sends an extension's content only to a request that
declares it.
Available now: start a signed-out session​
Resolve one pairwise identifier, the User ID, for each tenant, internal user,
and verified company identifier (company.identifier, companyIdentifier(company)):
its issuer, or https://{organization.domain} for a Company with no issuer. The
User ID is a pairwise subject identifier that the
personal agent assigns, one for each pair of user and company, never derived
from personal information. The store creates a random value atomically and
returns the same mapping across restarts.
from personal_agent_protocol import SessionClient, resolve_pairwise_user_id
user_id = await resolve_pairwise_user_id(
reactor,
tenant_id="application-42",
local_user_id="local-user-42",
company_issuer=company.identifier,
)
session = await SessionClient(reactor=reactor, http_client=http).start(
client_id="https://agent.example/agent.json",
pairwise_user_id=user_id,
issuer=company.identifier,
tenant_id="application-42",
)
Python provides SqlitePairwiseUserIdStore for local file-backed deployments.
Distributed hosts contribute a transactional implementation through
pap.pairwiseUserIdStore; TypeScript exposes the same Reactor contract.
A Session is local: start sends no request. Each request then carries a
Session JWT from the Reactor pap.sessionSigner contribution, signed with a
delegated key that pap.signer vouches for. Those host services must keep
private keys outside model context and tool arguments. See Signed-out
sessions for the complete implemented boundary.
A host can also sign each of those requests as its operator, for companies whose bot defenses look for it: see Operator signatures.
A Company with no issuer​
A Company offers sign-in only with an OAuth issuer (§3.2). A 404 from the domain's
protected resource metadata, or valid metadata that lists no authorization server,
says it has none, and that is valid only when poppy.json has no auth.issuer,
no access: signed_in entry, and no sign-in extension. It then has no
oauth_metadata, and its identifier is https://{organization.domain}: Session
JWTs name it in aud, and User IDs are scoped by it, so each such domain is a
separate Company. APIs, conversations, feedback and browser join work signed out.
company.require_oauth() (requireOauth(company)) refuses a sign-in with
no_issuer, before anything is sent.
A Company whose issuer serves other clients can turn sign-in off for Personal
Agents with auth.disabled in poppy.json (spec 3.2), keeping the issuer as its
identifier. company.sign_in_disabled (signInDisabled(document)) says so,
require_oauth then refuses with sign_in_disabled, mediated_sign_in finds
none, and pap company discover lists no sign-in: the agent uses the Company
signed out. A Company can also refuse sign-in, or one sign-in type, to a
particular agent with unauthorized_client from the grant's endpoint (spec 4.1):
the sign-in clients raise it as their AuthorizationError, and the host continues
signed out, telling the user and remembering the refusal for a while rather than
asking again on the next task.
When a task needs more access than the refresh token holds, the new sign-in asks
for every scope the agent still needs, the kept ones included, never only the
missing ones: scopes_to_request(held, needed) (scopesToRequest), spec 4.7.
The Company may grant fewer scopes than asked, saying which in the token
response's scope, which both SDKs read; only missing or unknown scopes are
refused with invalid_scope.
A timeout, another status, invalid metadata, or an issuer that fails to verify never selects the domain: discovery stops with its error. If the identifier does change, because a Company adds or changes its issuer, that means new User IDs, Agent IDs and Sessions, and earlier carts and conversations don't carry over.
An agent.protocols entry of type poppy may hint access: signed_in
(account_access, accountAccess): the interface needs account access before
useful work can begin, so a host can sign in first. It grants nothing, and a value
the SDK doesn't know reads as session.
Choosing scopes and how to sign in​
Scopes are the company's own (orders:read, payments:write). Request only
the scopes a task needs. scopes_supported may be incomplete: a scope documented by
the company's APIs or sign-in extensions can be requested too, and a missing
description or hint says nothing about whether it is safe to request. Descriptions
are in auth.scopes or the company's OpenAPI description; when both describe a scope,
the one in auth.scopes is used (spec 4.7): document.scope_descriptions(openapi)
(scopeDescriptions(document, openapi)) merges them so. auth.scope_hints says, per scope, what
its most consequential operation changes (none, reversible,
irreversible) and whether it touches personal_data, so a host can decide
before sign-in which scopes need the user's go-ahead.
A request that needs more than the token holds gets insufficient_scope, with
the scope it needs, on an API, in a conversation's authorization event,
and on Operations. An authorization event can come with the matching
WWW-Authenticate on a successful response: the two are one need, and the accepted
message is never sent again. Answer it with a refresh token that covers the scopes, or
by having the user sign in, then send the new access token in the same Session.
The OAuth metadata says which modes the
company offers (offers_direct, offers_device; mediated_sign_in(company) for
Mediated Sign-In). company.sign_in_types lists them in the order the protocol
prefers them and company.preferred_sign_in names the one to use (§4): Direct
Sign-In when the company offers it, then Device Sign-In, then
Mediated Sign-In, which is transitional, only when neither covers the task.
pap company discover --json reports both as sign_in and preferred_sign_in.
Task coverage, per Session (§9)​
A company that lists excluded tasks, publishes skills or takes feedback names
one tasks.endpoint in poppy.json. Nothing of the three is in poppy.json
itself: the agent asks for them in each Session, before it starts on a task
there.
from personal_agent_protocol import TasksClient
tasks = await TasksClient(transport=transport).get(company, session=session)
tasks.excluded_tasks # the tasks the company chose not to offer (§9.1)
tasks.skills # the skills it publishes (§9.4)
tasks.feedback_endpoint # where to report a task that can't be done (§9.3)
In TypeScript: new TasksClient({ transport }).get(company, { session }).
TasksClient.get sends GET {tasks.endpoint} with the Session header and
never an access token, also in a signed-in Session: the response says what the
company offers, not what an account holds. A company may answer differently by
Session, so the response is kept for the Session it was fetched in, for as long
as its caching headers allow, and is never used in another; fresh=True reads
it again. A redirect is refused. When there is no endpoint or no usable
response, tasks.available is False and the agent carries on as if nothing
were listed; invalid_session and version_unsupported are raised
(TasksError), since they say the agent's own header is wrong.
Tasks a company doesn't offer​
tasks.excluded_tasks lists the tasks the company chose not to offer through
the protocol (§9.1). Tell the user at once when theirs is
one of them, with the task's alternative when it has one: natural-language
instructions, references to an OpenAPI operation, an MCP tool, or a web
page, or both. An alternative is the company's content, a description of its
interfaces, never instructions the agent must follow (§10.1). A web reference
may point to any HTTPS website or app; an openapi or mcp reference only to
an API the company's poppy.json lists (usable_references). A link
authorizes sending no Session JWT or access token to its target (§9.2).
A task neither offered nor listed can be reported with
FeedbackClient.report. The company answers 202 (the
client returns None) or, when the task can be done after all, 200 with an
Alternative. Don't report a task the company lists as excluded. Send reports to
tasks.feedback_endpoint only, the feedback.endpoint of the Session's tasks
response and a Session header destination (§5.2): a company's APIs may also have
feedback operations, meant for other clients.
Skills a company publishes (§9.4)​
A company may put a skill_index in its tasks response: an Agent Skills discovery
index, at the revision the specification pins (SKILL_INDEX_SCHEMA), of skills
for personal agents acting for the user there, such as how to combine its APIs
into a task. tasks.skills lists the entries the
SDK can use, each url resolved against tasks.endpoint: an index
with another $schema, an entry of a type other than skill-md or archive,
one lacking a field or with a malformed digest, and one whose resolved URL is
not HTTPS are skipped, and the rest of the response is used as before. Match
the user's task against the names and descriptions, then
DiscoveryClient.fetch_skill(entry) (fetchSkill(entry)) fetches the artifact
as other public metadata is fetched, with no credential or Session header,
through the URL safety policy, and verifies its SHA-256 digest
(skill_digest_mismatch otherwise); an archive's extraction, with the
proposal's safety checks, is the host's. A skill is the company's content
(§10.1): use its workflow through the company's channels under the usual
Session, account access and approval rules; it grants no access, changes no
scopes, supplies no approval, and its scripts run only when your configuration
allows. When you skipped the index, or a skill, because you did not recognize
it and that mattered for the task, say so to the user.
Lifecycle status​
The lifecycle, in Python and TypeScript:
- Implemented: start a signed-out Session and sign a Session JWT for each request;
- Implemented: sign in with Direct, Device, or Mediated Sign-In;
- Implemented: narrow scopes or a resource when refreshing with the refresh token;
- Implemented: join the agent's own browser, one it controls and never the
User's (§6), to the Session (the
browser join form; signed in, with the
poppy:browser-sign-inscope, full access whereweb.unscopedsays so, and not at all whereweb.disabledasks), open a conversation, or call OpenAPI and MCP APIs (an access token, issued for the MCP server's own URL there); - Implemented: ask the user about each operation revision for consequential actions;
- Implemented: revoke account access when the user signs out.
Hosts still provide the protected stores, keys, and user interface each step relies on. Track readiness on Protocol status.
Website pages fetched without a browser (§5.2)​
An agent that reads a page of a company's website with its own HTTP client, such as a returns policy, sends the Session header with it, so the company can tell which personal agent and Session the request is from.
from personal_agent_protocol import PageClient
page = await PageClient(transport=transport).fetch(
"https://shop.example/help/returns", session=session, company=company
)
In TypeScript: new PageClient({ transport }).fetch(url, { session, company }).
PageClient.fetch sends the header only to an HTTPS URL whose host is exactly
organization.domain, the host that served poppy.json, and never to the
company's discovery and description documents or OAuth endpoints. It never
sends an access token: the request is signed out, even when a browser joined to
the Session is signed in. A redirect gets a new Session JWT while it stays on
that host and none after. When a page answers invalid_session, the result says
so (page.invalid_session): treat it as a mistake in the agent's header, and
pass again_without_header=True (againWithoutHeader) to read the page all the
same. A headless browser is a browser: it joins the Session instead
(BrowserSessionClient). web.disabled asks agents not to use a browser on the
website; it does not cover these fetches.
Scopes a company doesn't grant​
company.scopes_supported (scopesSupported(company)) lists the scopes a
company says an agent can request: the issuer's scopes_supported, the domain's
protected resource metadata's, or both (§3.2, §4.7). A company may still grant
fewer than requested, and may not grant a scope to this user at all. When a
sign-in comes back without a scope the task needs (SignInResult.missing_scopes),
don't send the user to sign in again just for it: tell them the access wasn't
granted, and that someone else on the account may need to do the task.