feat(agentex): forward user session cookie to agent pods via acp headers#250
Merged
cdvillegas merged 3 commits intoMay 27, 2026
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@greptile |
danielmillerp
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Summary
PR #245 added
x-acting-user-api-keyfor API-key callers. Browser and Ops Hub users authenticate with the_identityJwtsession cookie, so agent pods still had no delegatable credential.This PR extends runtime delegation v1 for cookie-based auth:
x-api-keypresent: forward asx-acting-user-api-key(unchanged from feat(agentex): forward user api key to agent pods via acp headers #245).Cookieheader and forward only allowlistedname=valuepairs onx-acting-user-cookie. Never replay the full browserCookieheader (no CSRF, analytics, or third-party cookies)._identityJwt(Scale Ops Hub / EGP / Spark). No Helm change required for default deployments.AGENTEX_DELEGATION_SESSION_COOKIE_NAMES(comma-separated). Unset = default. Empty string = cookie delegation disabled (API key path only).x-acting-user-cookie,x-selected-account-id,x-api-key, and rawcookieremain blocked on client passthrough; delegation values are server-set only.cookie(in addition to existing api-key redaction).Agent SDK
PassthroughResolverand agent-side SGP consumption remain follow-up work.Test Plan
tests/unit/domain/test_delegation_headers.py: API key and cookie paths, API key precedence, env unset/empty/override for cookie names, skip when no principal or agent identity, no credential.test_send_message_includes_cookie_delegation_headersonAgentACPService: asserts only_identityJwtis forwarded when extra cookies are present.TestFilterRequestHeaders: acting cookie and selected-account-id spoof headers stripped from passthrough.Linear Issue
Resolves AGX1-293
Greptile Summary
This PR extends runtime delegation for browser/Ops Hub users who authenticate with the
_identityJwtsession cookie rather than an API key. When a validated user principal is present, agentex parses the inboundCookieheader and forwards only allowlisted name-value pairs via a newx-acting-user-cookieACP header to agent pods.delegation_headers.py: Adds_minimal_session_cookie()(allowlist-only cookie filtering viaSimpleCookie) and extendsbuild_delegation_headers()with a cookie fallback path when no API key is present; cookie name allowlist is env-configurable with_identityJwtas the default.agent_acp_service.py: Blocksx-acting-user-cookieandx-selected-account-idfrom client passthrough inBLOCKED_HEADERSto prevent spoofing.request_utils.py: Addsr\"cookie\"to the log-redaction blacklist so inbound cookie headers are scrubbed from request logs.Confidence Score: 5/5
Safe to merge — cookie filtering is allowlist-only, spoofing protection is in place, and all credential paths are covered by tests.
The allowlist approach in _minimal_session_cookie is the right design: only explicitly named cookies ever leave agentex. Adding x-acting-user-cookie and x-selected-account-id to BLOCKED_HEADERS closes the client-spoofing vector before delegation headers are written. The env-based override lets operators disable cookie delegation entirely. Test coverage is thorough across all branches.
No files require special attention.
Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'main' into chris-villegas/..." | Re-trigger Greptile