Skip to content

feature: Session tracking for multiple concurrent sessions #182

Closed as not planned
Closed as not planned

Description

@huang195

Feature Description

Current architecture of using Envoy+Ext-proc for intercepting inbound/outbound traffic has the limitation of only be able to work with a single user at a time. When the agent is working on behalf of multiple concurrent users, our current mechanism will get confused, e.g., should we token exchange on behalf of user A or user B?

The inherit limitation here is that inbound connections and outbound connections are separate TCP connections, and there is no easy way to correlate these. Even Istio currently does not have a solution here.

Proposed Solution

There are several possible solutions:

  • Restrict to only a single session, e.g., queue additional requests in Envoy until the current active session has finished
  • Assume W3C Trace Context is being used, which requires cooperation from agent code.
  • Assume tokens from inbound path are always propagated to outbound requests (as part of SDK or manually done by developer), and we can use fields of the token, e.g., sid to track sessions.
  • Explore if eBPF could be used to correlate inbound and outbound sessions/threads

Want to contribute?

  • I would like to work on this issue.

Additional Context

No response

Activity

  1. self-assigned this
    on Mar 9, 2026
  2. davidhadas commented on Mar 9, 2026

    @davidhadas
    Contributor

    How about the following:

    • By default: restrict to only a single session, e.g., queue additional requests in Envoy until the current active session has finished
    • If the agent card declares that the agent supports W3C Trace Context, use it and support multiple concurrent sessions (AuthBridge should verify that the agent indeed sends out W3C Trace Context as expected and if not terminate the pod).
    • if the agent card declares that the agent supports token transfer (assuming we define the expected behavior clearly), use the token transfer and support multiple concurrent sessions (AuthBridge should verify that the agent indeed behave as expected - transfers the tokens, and if not terminate the pod).
  3. huang195 commented on Mar 10, 2026

    @huang195
    MemberAuthor

    @davidhadas thanks for your comments. Let's go into more details:

    By default: restrict to only a single session, e.g., queue additional requests in Envoy until the current active session has finished

    The problem with this approach is that this is fine if our end goal is to build a demo without concurrency. In an enterprise and/or prod environment, limiting concurrency to one will be very restrictive given agent <-> LLM queries could take seconds if not longer to finish.

    If the agent card declares...

    Agent card is a runtime construct, but AuthBridge is instantiated along with the agent before the agent runs. This would mean we would need to wait till the agent code to be fully operational and query for its agent card before we allow any traffic to go through. This would increase agent's startup time. This is fine, but seem to add unnecessary dependencies between the moving parts.

    I'm currently leaning more toward what @maia-iyer suggested to me after our call:

    Assume tokens from inbound path are always propagated to outbound requests (as part of SDK or manually done by developer), and we can use fields of the token, e.g., sid to track sessions.

    The reason is that when users/clients communicate with agents, they always pass in a token so the agent knows who it is working for. If we can make this assumption, using various fields of the token, e.g., sid, would allow us to uniquely identify different users/clients. This seems to be a cleaner solution. One problem is that AFAIK if the token is ever refreshed in the middle of a session, the sid embedded in the token might change. If so, we could use issuers+sub fields, which shouldn't change across token renewals. Another caveat of this approach is that agent code is responsible for propagating the necessary HTTP headers from inbound path to outbound path, which is also what Istio recommends for session tracking for their users.

  4. huang195 commented on Mar 10, 2026

    @huang195
    MemberAuthor

    After some exploration of the eBPF approach, it would seem that we would need to deal with different runtimes, e.g., Go, Python, etc., that agent code could be written with. For some runtimes like Go, it would be extremely difficult, if impossible, to build up the correct correlation using only kernel level information without having more insights on application level semantics. So, scratch this:

    Explore if eBPF could be used to correlate inbound and outbound sessions/threads

  5. webchang commented on Mar 10, 2026

    @webchang
    Member
  6. davidhadas commented on Mar 10, 2026

    @davidhadas
    Contributor

    By default: restrict to only a single session...

    ...limiting concurrency to one will be the agent was not built to support concurrency when running on Kagenti, this is the best we can do. So unless there is some way to discern the outbound traffic and identify which of the sessions related to what user, this is what we can do. The admin can deploy multiple pods to support concurrency where each pod will support a single session at a time.

    If the agent card declares...

    ...
    I'm currently leaning more toward what @maia-iyer suggested to me after our call:

    @huang195,
    Please document here all alternatives being discussed, pros and cons of each approach and the conclusions.
    (how else would we know what was the suggestion and how it solves this issue :) )

  7. huang195 commented on Mar 10, 2026

    @huang195
    MemberAuthor

    @davidhadas all the alternatives (so far) are listed in the first post. I'm hoping that we can discuss the pros and cons of each in this issue, and in the process, we can find out more things about each approach as we discuss. This will help us drive toward a conclusion.

  8. davidhadas commented on Mar 10, 2026

    @davidhadas
    Contributor

    Apologies, I misunderstood your previous answer.
    As you pointed, the fact that tokens come from the user is not helping us on the outbound unless the agent deliver the tokens to the outbound or otherwise allow us to know which communication relate to which user session.

    Hence we need some mechanism to verify that the agent do deliver this information in the outbound, before we can allow the agent to use concurrency per pod.

  9. huang195 commented on Mar 10, 2026

    @huang195
    MemberAuthor

    @davidhadas agreed, we need a way to verify that the agent propagates session identity on outbound requests.

    My proposal is to keep this simple and go with token propagation as the single approach:

    • Agents are expected to propagate the inbound token (or relevant fields like iss+sub) to outbound requests. This is a common pattern — Istio recommends the same for their users when correlating inbound/outbound traffic.
    • AuthBridge verifies on the outbound path that the token/session identifier is present and matches a known inbound session. If it's missing or doesn't match, the request is blocked.

    This gives us one clean mechanism to implement, verify, and reason about. The tradeoff is that agent developers must propagate the token, but that's a reasonable expectation since they already receive it on the inbound path and most well-behaved agents will pass credentials along to downstream services anyway.

    There's another related issue: #174. As you can see, from my latest comment, the additional "burden" on agent developer to propagate token is literally adding 1 line in the code. T

  10. 5 remaining items

  11. webchang commented on Mar 26, 2026

    @webchang
    Member

    Per our separate discussions, Section 2.3, How the Design Handles Multi-User Concurrency in the document kagenti_mcp_flow-20260316.docx (located in the Box folder AgentPlatform > SecurityArchitecture),
    summaries how the requested feature for MCP scenarios can be delivered based on current Kagenti implementation.

    However, the enhanced Kagenti runtime for MCP does not address the session tracking issue for more general A2A scenarios.

    @huang195 Would it make sense to create a separate feature request to cover general A2A scenarios?

  12. huang195 commented on Apr 6, 2026

    @huang195
    MemberAuthor

    @msteinder sorry, I just saw your comment regarding:

    It seems that the problem you are describing might have been solved here: https://github.com/husky-parul/trust-graph-dataplane, demo is here https://www.youtube.com/watch?v=ywanNEIUfog

    Looking at the repo, it looks they're using the same method that we have concluded as well. Essentially, it requires code changes/collaboration from the agent. In their chat-agent, they would need to propagate certain headers to correlate incoming requests to outgoing requests through the agent, e.g.,

    headers = {
        "x-request-id": incoming_request.headers.get("x-request-id"),
        "x-principal-id": incoming_request.headers.get("x-principal-id"),
    }
    requests.post(downstream_url, headers=headers)
    
  13. esnible commented on Apr 28, 2026

    @esnible
    Member

    "Multiple concurrent sessions" is key. There are different communication patterns used by an agent. Sometimes an agent is single-user, one-request-at-a-time. Other agents are multi-user and long running.

    For example, imagine asking an agent "Tell me when Taylor Swift announces a concert within two hours drive of

    . Poll her tour website every four hours for the next 365 days". Ten people might make such a request, and it will be hard to associate the outgoing polls, which will happen for 365 days after the incoming request.

    Some ways we know to associate incoming and outgoing:

    • The TRACEPARENT header
    • User identity in JWT bearer tokens
    • Associating a kernel thread that receives a TCP packet with the TCP packets sent by that thread

    The only mechanism that really works is TRACEPARENT. Can we use that? Should we propose a new header for this purpose?

  14. moved this from Backlog to In progress in Rossoctl Issue Prioritizationon May 4, 2026
  15. moved this from In progress to Backlog in Rossoctl Issue Prioritizationon May 4, 2026
  16. davidhadas commented on Jun 6, 2026

    @davidhadas
    Contributor

    @huang195
    one concern is that the option we seem to like best (agent forwarding the token) will not work well with agents that seek to use their own tokens (e.g. using passthrough routes). Such agents will send their own token and we still may prefer to have a way to correlate the outbound to the inbound...

    So we may need a header for such agents such as "X-INBOUND-TOKEN: {placeholder}" this can be the same abph_k7Xm9pL2qR4sT6uV8wY0zA1bC3dE5fG6hI7jK8lM used now in placeholder_mode: true for example or alternative
    We can push this header always and let agents decide what they do (either pass the X-INBOUND-TOKEN header or the AUTHORIZATION header).

  17. huang195 commented on Jul 13, 2026

    @huang195
    MemberAuthor

    @davidhadas see #626 as an example plugin that does something you described above.

  18. github-actions commented on Sep 12, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this issue is still relevant, please comment or remove the stale label.

  19. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue was closed because it has been stale for 14 days with no activity. Feel free to reopen if this is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions