Title: feat(a2a): per-request agent-card URL resolution (follow-up to #616) · Issue #647 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(a2a): per-request agent-card URL resolution (follow-up to #616) · Issue #647 · adcontextprotocol/adcp-client-python
X Title: feat(a2a): per-request agent-card URL resolution (follow-up to #616) · Issue #647 · adcontextprotocol/adcp-client-python
Description: Problem (follow-up to closed #616) PR for #616 shipped Option A — the static serve(public_url=...) kwarg — and the issue closed COMPLETED. Option B (trust_forwarded_headers for per-request resolution) was explicitly deferred per the dx-e...
Open Graph Description: Problem (follow-up to closed #616) PR for #616 shipped Option A — the static serve(public_url=...) kwarg — and the issue closed COMPLETED. Option B (trust_forwarded_headers for per-request resoluti...
X Description: Problem (follow-up to closed #616) PR for #616 shipped Option A — the static serve(public_url=...) kwarg — and the issue closed COMPLETED. Option B (trust_forwarded_headers for per-request resoluti...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/647
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(a2a): per-request agent-card URL resolution (follow-up to #616)","articleBody":"## Problem (follow-up to closed #616)\n\nPR for #616 shipped Option A — the static `serve(public_url=...)` kwarg — and the issue closed COMPLETED. Option B (`trust_forwarded_headers` for per-request resolution) was [explicitly deferred](https://github.com/adcontextprotocol/adcp-client-python/issues/616) per the dx-expert review.\n\nThis is fine for single-host deployments. **For multi-tenant subdomain deployments, where every tenant has its own public host, the static kwarg can only advertise one URL.** Adopters still need a per-request rewrite to surface the correct tenant host in `/.well-known/agent-card.json`.\n\n## Concrete adopter scenario\n\n[bokelley/salesagent](https://github.com/bokelley/salesagent) runs multi-tenant on subdomains: `acme.scope3.com`, `beta.scope3.com`, etc. Each tenant's buyer agent fetches the agent card from its own host. A static `public_url=https://scope3.com/` would advertise the wrong host to every non-apex tenant.\n\nToday we work around this with a 190-LOC ASGI middleware ([core/middleware/agent_card_public_url.py](https://github.com/bokelley/salesagent/blob/main/core/middleware/agent_card_public_url.py)) that buffers the `/.well-known/agent-card.json` response and rewrites localhost URLs from `X-Forwarded-Host` per request. It composes cleanly with the new static kwarg (only rewrites loopback, so it no-ops when `public_url` is set) but it's adopter-side code maintaining an SDK-shaped behaviour.\n\n## Proposed shape\n\nTwo options, both addressing the per-request case the deferral explicitly called out:\n\n**A) `serve(trust_forwarded_headers=True)`** — when set, the agent-card route honours `X-Forwarded-Host` and `X-Forwarded-Proto` at response-build time. Defaults to `False` so unconfigured behaviour is unchanged. Concerns from the original deferral:\n\n- *Trust boundary*: gate via the kwarg — adopters explicitly opt in only when they know they're behind a trusted proxy. Matches how Flask / FastAPI / starlette handle the same headers.\n- *Thread-safety on shared `pb.AgentCard`*: build the response card per-request rather than once at server-init. The card payload is small, the marginal CPU is negligible vs. the network IO.\n\n**B) `serve(public_url=Callable[[Request], str])`** — accept a callable in addition to a static string. Adopters provide the resolution logic themselves. More general, less opinionated about trust boundaries.\n\nEither closes the multi-tenant subdomain gap. **A** is the cleaner zero-config option for the common case (most multi-tenant adopters have a reverse proxy that sends `X-Forwarded-Host`); **B** keeps the SDK out of the trust-policy business at the cost of every adopter writing the resolver.\n\n## Why a new issue vs reopening #616\n\n#616 closed COMPLETED — fine, the static kwarg is real and useful. Re-opening it would muddy the changelog. This is a separate ask that depends on the closed work landing first.\n\n## Source\n\nOur deferral entry in [bokelley/salesagent core/SDK_FEEDBACK.md](https://github.com/bokelley/salesagent/blob/main/core/SDK_FEEDBACK.md): \"make the agent-card URL `X-Forwarded-Host`-aware when no static `public_url` is configured, OR accept a `Callable[[Request], str]` for per-request resolution.\"\n\nLocal tracker: bokelley/salesagent#103.\n\n## Related\n\n- #616 (closed; Option A shipped)\n- #621 (PR that shipped Option A)\n","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-11T06:22:55Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/647"}
| 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:ce9227c3-c03e-79e0-652b-a60f6d0a0529 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E42E:34DB8F:1B3986D:245A263:6B016527 |
| html-safe-nonce | a5af35fd050032925072f7fbab01a4eaa4293a50378b6ea8c6d51f5648e0e083 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDJFOjM0REI4RjoxQjM5ODZEOjI0NUEyNjM6NkIwMTY1MjciLCJ2aXNpdG9yX2lkIjoiMzA4ODUxMjE5OTgyNDU5ODMxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9584d2ca94961ecdc89e77b1186edf051874e927c5481c304f6e66f5c35059ea |
| hovercard-subject-tag | issue:4418528290 |
| 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/647/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77b6c78cc4bca2cd84daa297e06f83e7ae682257d364e95b1e392779df9a1126/adcontextprotocol/adcp-client-python/issues/647 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77b6c78cc4bca2cd84daa297e06f83e7ae682257d364e95b1e392779df9a1126/adcontextprotocol/adcp-client-python/issues/647 |
| og:image:alt | Problem (follow-up to closed #616) PR for #616 shipped Option A — the static serve(public_url=...) kwarg — and the issue closed COMPLETED. Option B (trust_forwarded_headers for per-request resoluti... |
| 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 | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width