Traces and analytics, without secrets
Both SDKs report each protocol stage they complete โ discovery, a Session
start, each sign-in step, each conversation call, each operation asked about
or sent โ to a pap.telemetry sink the host
contributes through Reactor. Without a sink nothing is emitted, and nothing
changes.
Each stage is one TelemetryEvent: its name, its stage, ok or error, its
duration, and attributes. One event is what a trace exporter turns into a span
and what an analytics pipeline counts, so traces and analytics see the same
data.
Redacted by constructionโ
Attributes come from an allowlist (TELEMETRY_ATTRIBUTES), and each value
must pass its rule; a value that fails is dropped, and a name outside the list
is a programming error the SDK refuses:
| Attribute | Value |
|---|---|
pap.stage | discovery, session, sign_in, conversation, operation, or company |
pap.outcome | ok or error |
pap.error | the refusal's error code, a lowercase identifier; unexpected for anything else |
pap.company.domain | a DNS name |
pap.company.issuer | an https origin with at most a plain path: no user information, query, or fragment |
pap.sign_in.method | direct, device, mediated, or refresh_token |
pap.sign_in.status | the step's status, a lowercase identifier (pending, complete, signed_out, โฆ) |
pap.session.signed_in | a flag |
pap.scopes.granted, pap.scopes.missing | counts |
pap.conversation.working, pap.conversation.closed | booleans (ยง8.7) |
pap.conversation.handoff | a lowercase identifier (none, pending) |
pap.conversation.events | a count |
pap.operation.status | lowercase identifiers (approved, answered, new_revision, unknown) |
pap.client.id | the personal agent's client_id, once the company verified it: an https URL with a plain path |
pap.interface | agent, openapi, mcp, or web |
pap.company.route | the company route a request took (oauth_token, poppy_conversations, mcp, โฆ), never its path |
pap.http.status | the status the company answered |
pap.replayed | a flag: the refusal was a Session JWT or assertion already used |
No rule admits a token, an assertion, a Session JWT, a code, a cookie, a password, a mediated field, a Session, conversation or operation ID, a pairwise User ID, or a URL with a query: the SDK never offers them, and none could pass. An error event carries the refusal's code only, never its message or the company's answer. A sink that throws is logged by its exception type alone and never fails the protocol call; two sinks at the winning order fail closed, as every optional point does.
The canary suites hold this to a real run in both languages
(test_canaries.py, canaries.test.mjs): every Reactor of the demo worlds
has a sink, and no credential exchanged on the wire may appear in any event,
as analytics JSON or as the span the OpenTelemetry adapter starts. See
Security.
| Event | Stage |
|---|---|
pap.discovery.discover | discovery |
pap.session.start | session |
pap.sign_in.direct.begin, pap.sign_in.direct.complete | sign_in |
pap.sign_in.device.begin, pap.sign_in.device.poll | sign_in |
pap.sign_in.mediated.sign_in, pap.sign_in.mediated.submit_code | sign_in |
pap.sign_in.refresh_token.refresh, pap.sign_in.refresh_token.revoke | sign_in |
pap.conversation.start, .send, .read_events, .start_direct, .accept_user_request, .handoff, .close | conversation |
pap.operation.ask_user, .send | operation |
pap.company.identity.check, .session.start, .interface.switch, .sign_out, .refused | company |
What a company reportsโ
A company built on the SDK's company service (personal_agent_protocol.company,
the TypeScript CompanyService) reports through the same point, with stage
company, when its Reactor has a sink:
pap.company.identity.checkโ a personal agent's identity verified for the first time, or with new metadata (not every request it signs);pap.company.session.startโ a Session started;pap.company.interface.switchโ a Session moved to another interface: a request at the MCP server (mcp), a browser joining it (web);pap.company.sign_outโ a whole sign-in ended: revoked by its agent, by a password reset, or by the host (outside a request it carries no route or agent);pap.company.refusedโ each request it refused, aserror, with the protocol's code, the route, the status and whether a Session JWT or assertion was a replay. The device flow'sauthorization_pendingandslow_downare progress, not refusals, and a path the company does not serve is nobody's.
A host that keeps an audit โ who did what at its company โ turns these events
into its own records: they carry the issuer, the agent's client_id and the
code, never what was sent.
OpenTelemetryโ
The OpenTelemetry adapter makes each event a span of the host's tracer, under
the span current when the stage ran; a failed stage's span has an error status
and no description. The dependency stays optional: in Python install the
telemetry extra (opentelemetry-api); in TypeScript pass any
@opentelemetry/api tracer, which the adapter uses structurally.
import asyncio
from opentelemetry import trace
from reactor import PluginManifest
from personal_agent_protocol import (
TELEMETRY_SINKS,
DiscoveryClient,
OpenTelemetrySink,
build_pap_reactor,
)
class Telemetry:
"""The host's sink: the SDK's protocol stages as spans of the host's tracer."""
def provide_contributions(self, contributions) -> None:
sink = OpenTelemetrySink(trace.get_tracer("my-personal-agent"))
contributions.contribute(TELEMETRY_SINKS, sink, contribution_id="otel", order=50)
async def main() -> None:
reactor, _ = build_pap_reactor(
plugins=[(PluginManifest(name="telemetry", version="1"), Telemetry())]
)
async with DiscoveryClient(reactor=reactor) as client:
await client.discover("example.com") # one span: pap.discovery.discover
asyncio.run(main())
import {
TelemetrySinks,
buildPapReactor,
discoverCompany,
openTelemetrySink,
} from "@datalayer/personal-agent-protocol";
// `tracer` is the host's OpenTelemetry tracer: trace.getTracer("my-personal-agent").
const reactor = buildPapReactor({}, [
{
name: "telemetry",
contributes: [
{ point: TelemetrySinks, value: openTelemetrySink(tracer), options: { id: "otel", order: 50 } },
],
},
]);
const company = await discoverCompany("example.com", { reactor }); // one span: pap.discovery.discover
Analyticsโ
For analytics, contribute any object with record(event): event.as_dict()
(JSON.stringify(event) in TypeScript) is the event as JSON, ready for a
pipeline. RecordingTelemetrySink keeps events in memory, for tests. The
telemetry
Pydantic AI example hands a model the events of a whole journey with
Manzanita, which is safe precisely because they hold nothing secret.