Title: ctx.caller_identity is composite scope-key, not bare principal_id (docs misleading) · Issue #571 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: ctx.caller_identity is composite scope-key, not bare principal_id (docs misleading) · Issue #571 · adcontextprotocol/adcp-client-python
X Title: ctx.caller_identity is composite scope-key, not bare principal_id (docs misleading) · Issue #571 · adcontextprotocol/adcp-client-python
Description: What The RequestContext docstring (adcp/decisioning/context.py:476-509) describes auth_principal as "who's calling" and caller_identity as "what's the cache scope key" / opaque. In practice for bearer-token adopters: BearerTokenAuthMiddl...
Open Graph Description: What The RequestContext docstring (adcp/decisioning/context.py:476-509) describes auth_principal as "who's calling" and caller_identity as "what's the cache scope key" / opaque. In practice for bea...
X Description: What The RequestContext docstring (adcp/decisioning/context.py:476-509) describes auth_principal as "who's calling" and caller_identity as "what's the cache scope key" /...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/571
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ctx.caller_identity is composite scope-key, not bare principal_id (docs misleading)","articleBody":"## What\n\nThe `RequestContext` docstring (adcp/decisioning/context.py:476-509) describes `auth_principal` as \"who's calling\" and `caller_identity` as \"what's the cache scope key\" / opaque. In practice for **bearer-token adopters**:\n\n- `BearerTokenAuthMiddleware` populates `current_principal` ContextVar with the bare principal_id (whatever the adopter's `validate_token` returns on `Principal.caller_identity`)\n- `auth_context_factory` reads that contextvar and sets `ToolContext.caller_identity` from it\n- BUT — by the time downstream `_impl` code reads `ctx.caller_identity`, it's been **mutated to the composite scope key** `\u003cstore_module>.\u003cstore_qualname>:\u003caccount_id>` (e.g., `core.stores.accounts.SalesagentAccountStore:wonderstruck:default`)\n- `ctx.auth_principal` stays `None` for bearer flows — that field only populates on signed-request flows where AuthInfo.principal is set\n\nNet: a bearer-token adopter trying to read \"who's calling?\" from `ctx.caller_identity` gets the composite, not the bare id. salesagent's `_create_media_buy_impl` uses `identity.principal_id` for a Principal-table lookup, which 404'd on the composite key.\n\n## Repro\n\n```python\n# core/platforms/_delegate.py\ndef _build_identity(ctx):\n # WRONG — returns composite scope-key in bearer flows\n principal_id = ctx.caller_identity # → \"core.stores.accounts.SalesagentAccountStore:wonderstruck:default\"\n return ResolvedIdentity(principal_id=principal_id, ...)\n```\n\nThe fix in salesagent was to import the framework's contextvar directly:\n\n```python\nfrom adcp.server.auth import current_principal\nprincipal_id = current_principal.get() # bare value, e.g. \"wonderstruck_buyer\"\n```\n\nThat works but requires reaching into module-private state.\n\n## What we'd want\n\nEither:\n1. Docs clarify that `caller_identity` is mutated to composite by downstream framework code, and document the correct read path for bearer adopters (`adcp.server.auth.current_principal.get()` or a typed helper)\n2. Populate `ctx.auth_principal` from the bearer flow too — give bearer adopters a typed read for \"who's calling\" without reaching into ContextVars\n3. Stop mutating `ctx.caller_identity` from its initial bare-id value; do composite-scoping inside the idempotency middleware via a separate field\n\n(2) is probably the cleanest — `auth_principal` already exists as the \"typed convenience field\"; populating it on bearer flows matches its docstring intent.\n\n## Filed by\n\nsalesagent live GAM CRUD probe — surfaced when `_create_media_buy_impl` Principal lookup failed because identity.principal_id was the composite. Tracked as salesagent #42.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-04T13:11:21Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/571"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4729cad1-9f82-6397-941e-84d208256997 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1DE:2C4BED:D165E8:10B694E:6B010275 |
| html-safe-nonce | 7e5d0acbb3859416bf7e38b71d7d6be04129809618c327802be39e8cf3b491db |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMURFOjJDNEJFRDpEMTY1RTg6MTBCNjk0RTo2QjAxMDI3NSIsInZpc2l0b3JfaWQiOiIyNzY3MzgzNTAzNzYxOTAwMTQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fde29deb2acf4488b3249a659801c8f8c0bb3d22f467b99157b0aa135edb1e52 |
| hovercard-subject-tag | issue:4376836669 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/571/issue_layout |
| twitter:image | https://opengraph.githubassets.com/29d203822886ba637a115e0193477d2559bfa6bec2f37cb5a47d9c88a9512572/adcontextprotocol/adcp-client-python/issues/571 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/29d203822886ba637a115e0193477d2559bfa6bec2f37cb5a47d9c88a9512572/adcontextprotocol/adcp-client-python/issues/571 |
| og:image:alt | What The RequestContext docstring (adcp/decisioning/context.py:476-509) describes auth_principal as "who's calling" and caller_identity as "what's the cache scope key" / opaque. In practice for bea... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width