You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feat]: passing call context to unauthenticated card modifier #657
Is your feature request related to a problem? Please describe.
We are wondering if support can be added for passing the call context to the regular agent card modifier, just as it is for the extended card modifier.
Describe the solution you'd like
Agent card modifiers should be given a second parameter for the call context, matching the signature of extended agent card modifiers.
Describe alternatives you've considered
We can construct our own Application and Adapter classes to override the get agent card endpoint handling, but this is cumbersome and hard to maintain.
Additional context
I guess we're also wondering if this is intentional - i.e. if agent cards should not depend on anything from the call context. In our case, we want to use part of the request URL (which is dynamic) as part of the url field in the response. Also, if we work to add support for this (like in #647), do we have to make the change backwards compatible and support modifiers that don't take in the call context (i.e. only have one parameter for the agent card to be modified)? I think anything goes as long as we're on the 0.X.Y versions (i.e. anything below 1.0), but just want to make sure.
As with #647 I am more than willing to lead development on this.
Looking at the current card_modifier signature, extending it to optionally accept a ServerCallContext is a backwards-compatible change if we use inspect to detect the arity, or just overload with two signatures. The cleaner approach:
Users who don't need the context just ignore the second arg. This is cleaner long-term but requires updating every existing modifier.
Where to plumb context in
The card modifier is called from the .well-known/agent-card handler. That route currently doesn't build a ServerCallContext at all — it's a pure GET that sidesteps the normal request-handler machinery. So the fix needs two parts:
Have the card endpoint build a ServerCallContext from request headers (at minimum user if an auth middleware populated it, plus request_headers).
Pass that context into the card modifier.
Motivating use case
Per-user feature flags, regional URLs, or auth-state-dependent skills — e.g. hide skills.premium.* for free-tier callers based on a JWT claim. All of these are impossible today without a fork.
Related
This ties into #445 (client auth handling) and #281/#168 (trace context propagation) — they're all symptoms of the same gap: the .well-known/agent-card endpoint is disconnected from the main request pipeline. Might be worth a single PR that introduces a CardRequestContext and uses it in all three places.
I can prep a PR with Option A if that's the preferred direction.
Hey @cbugwadia32, I am afraid ServerCallContext does not fit that well into a well-known agent card endpoint (i.e. tenant and user).
Could you please expand a bit more on your use-case with dynamic URLs? Also worth mentioning that with modular routing in 1.0 SDK you can have fully custom handler for a well-known path only which is quite trivial: agent_card_routes.py.
Other examples from the "Motivating use case" section from the above comment by @mtsmyassin actually belong to extended agent card which takes user context into account by design (see 3.1.11. Get Extended Agent Card).
I started following this PR because our agent is accessible from at least 2 urls (publicly and internally to avoid clients hitting the internet). As of today, I have a big hack of a workaround to get the request context injected into the handler so that I can use the x-forwarded headers to reconstruct the base url of the incoming request
@ishymko - our use case is that the URL of the agent (which is part of the agent card) depends on the path to the agent card itself, e.g. if the public agent card is accessed at /agent/id123456/.well-known/agent-card.json then I want the response to include /agent/id123456 in the URL. If the v1 offering lets us achieve this somehow then we're good with that.
Activity
rohityan commentedon Feb 3, 2026
Hi @cbugwadia32 , We'll review this internally and get back to you with an update on its implementation status.
mtsmyassin commentedon Apr 17, 2026
Suggested API
Looking at the current
card_modifiersignature, extending it to optionally accept aServerCallContextis a backwards-compatible change if we useinspectto detect the arity, or just overload with two signatures. The cleaner approach:Option A: Second-arg
contextwith a defaultThis lets existing single-arg modifiers keep working while new two-arg ones receive the call context.
Option B: Single new signature (breaking)
If you're OK with a major-version breaking change, just change the signature:
Users who don't need the context just ignore the second arg. This is cleaner long-term but requires updating every existing modifier.
Where to plumb
contextinThe card modifier is called from the
.well-known/agent-cardhandler. That route currently doesn't build aServerCallContextat all — it's a pure GET that sidesteps the normal request-handler machinery. So the fix needs two parts:ServerCallContextfrom request headers (at minimumuserif an auth middleware populated it, plusrequest_headers).Motivating use case
Per-user feature flags, regional URLs, or auth-state-dependent skills — e.g. hide
skills.premium.*for free-tier callers based on a JWT claim. All of these are impossible today without a fork.Related
This ties into #445 (client auth handling) and #281/#168 (trace context propagation) — they're all symptoms of the same gap: the
.well-known/agent-cardendpoint is disconnected from the main request pipeline. Might be worth a single PR that introduces aCardRequestContextand uses it in all three places.I can prep a PR with Option A if that's the preferred direction.
ishymko commentedon May 27, 2026
Hey @cbugwadia32, I am afraid
ServerCallContextdoes not fit that well into a well-known agent card endpoint (i.e.tenantanduser).Could you please expand a bit more on your use-case with dynamic URLs? Also worth mentioning that with modular routing in 1.0 SDK you can have fully custom handler for a well-known path only which is quite trivial: agent_card_routes.py.
Other examples from the "Motivating use case" section from the above comment by @mtsmyassin actually belong to extended agent card which takes user context into account by design (see 3.1.11. Get Extended Agent Card).
DanCardin commentedon May 27, 2026
I started following this PR because our agent is accessible from at least 2 urls (publicly and internally to avoid clients hitting the internet). As of today, I have a big hack of a workaround to get the request context injected into the handler so that I can use the x-forwarded headers to reconstruct the base url of the incoming request
cbugwadia32 commentedon Jun 1, 2026
@ishymko - our use case is that the URL of the agent (which is part of the agent card) depends on the path to the agent card itself, e.g. if the public agent card is accessed at
/agent/id123456/.well-known/agent-card.jsonthen I want the response to include/agent/id123456in the URL. If the v1 offering lets us achieve this somehow then we're good with that.github-actions commentedon Jun 16, 2026
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
github-actions commentedon Jun 29, 2026
This issue was closed because it has been inactive for 27 days. Please post a new issue if you need further assistance. Thanks!