Skip to content

How to pass custom HTTP headers to ADK agents in Vertex Agent Engine? #5012

Closed

Description

@shashankram

I tried a bunch of things and have been unable to pass custom HTTP headers to an ADK agent running in Vertex Agent Engine. Is there a documented way to allow clients calling the Vertex Agent Engine's endpoint to passthrough custom headers required by the agent?

E.g., code where I try to set the state via the state attribute while creating the session. Note that headers is stripped out and there's nothing in the invocation_context.session.state

    # Create a new session
    response = requests.post(
        f"{BASE_URL}:query",
        headers=headers(),
        data=json.dumps(
            {
                "class_method": "async_create_session",
                "input": {
                    "user_id": USER_ID,
                    "state": {
                        "x-foo": "foo",
                    },
                },
            }
        ),
    )
    response.raise_for_status()
    session = response.json()
    print(f"Created session: {session}")

    session_id = session.get("session_id") or session.get("id")

    # Stream a query to the agent
    response = requests.post(
        f"{BASE_URL}:streamQuery",
        headers=headers(),
        data=json.dumps(
            {
                "class_method": "async_stream_query",
                "input": {
                    "user_id": USER_ID,
                    "session_id": session_id,
                    "message": "What can you do?",
                },
            }
        ),
        stream=True,
    )

Activity

  1. added
    agent engine
    on Mar 26, 2026
  2. self-assigned this
    on Mar 30, 2026
  3. klateefa commented on Mar 30, 2026

    @klateefa

    @shashankram Thanks for reporting this. Could you share a few more details so we can look into the bug better? Specifically, what ADK version are you using, how did you deploy the agent to Vertex Agent Engine, This will help us figure out better. Also, if you’re not on the latest version of ADK, please try updating and see if the issue persists.

  4. added
    request clarification
    on Apr 17, 2026
  5. surajksharma07 commented on May 27, 2026

    @surajksharma07
    Collaborator

    @shashankram — just following up here. Passing initial metadata via the state field in async_create_session is actually the supported ADK mechanism for getting custom context into invocation_context.session.state, so if that's being stripped it could be deployment-specific behavior worth investigating with the details klateefa asked for on Mar 30 (ADK version + deployment method).

    Since we haven't heard back since the issue was opened, going ahead and closing this out — feel free to reopen and share those details if you're still seeing the state come back empty!

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

Metadata

Metadata

Labels

agent enginerequest clarification

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions