Skip to content

service_level = "priority" does not work with VertexAI聽#7263

Closed as not planned
Closed as not planned

Description

@SaeeSaadat

馃敶 Required Information

Describe the Bug:
The following configuration for an agent works with an API Key, but not with VertexAI


pim_agent = Agent(
    model=Gemini(
        model="gemini-3.8-flash"
    ),
    name="root_agent",
    description="...",
    instruction=instruction,
    generate_content_config=types.GenerateContentConfig(
        temperature=0.5,
        max_output_tokens=8192,
        safety_settings=[
            types.SafetySetting(
             category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
             threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH,
            )
        ],
    ),
)

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:
With ADK 2.9.1, configure the agent according the provided snippet and run adk web
Setup the environment variables with GOOGLE_CLOUD_PROJECT=... and GOOGLE_GENAI_USE_VERTEXAI=1

Expected Behavior:
When
GOOGLE_GENAI_USE_VERTEXAI=0
The agent works fine with the priority service level

Observed Behavior:
but with VERTEXAI=1 it produces the following error:

google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Invalid value at \'service_tier\' (type.googleapis.com/google.cloud.aiplatform.v1beta1.ServiceTier), "priority"', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'service_tier', 'description': 'Invalid value at \'service_tier\' (type.googleapis.com/google.cloud.aiplatform.v1beta1.ServiceTier), "priority"'}]}]}}

Environment Details:

  • ADK Library Version (pip show google-adk): 2.9.1
  • Desktop OS:** [e.g., macOS, Linux, Windows]: Windows with WSL2
  • Python Version (python -V): 3.14

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-3.8-flash

馃煛 Optional Information

Providing this information greatly speeds up the resolution process.

Regression:
Did this work in a previous version of ADK? If so, which one?
2.8 had the same behavior

Additional Context:
Similar issue in genai:
googleapis/python-genai#2433

How often has this issue occurred?:

  • Always (100%)

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Sep 25, 2026
  2. llalitkumarrr commented on Sep 28, 2026

    @llalitkumarrr
    Collaborator

    Hello @SaeeSaadat,

    We tried to reproduce this issue using version 2.9.2 but we did not get any errors. Could you please try this version and share your observations? For your reference the code we used for the reproduction is provided below.

    from google.adk import Agent
    from google.adk.models.google_llm import Gemini
    from google.adk import Runner
    from google.adk.sessions import InMemorySessionService
    import asyncio
    from google.genai import types
    from dotenv import load_dotenv
    load_dotenv(override=True)
    
    
    pim_agent = Agent(
        model=Gemini(
            model="gemini-3.8-flash"
        ),
        name="root_agent",
        description="Help full assistant",
        instruction="You are a helpful assistant that answers user queries.",
        generate_content_config=types.GenerateContentConfig(
            temperature=0.5,
            max_output_tokens=8192,
            safety_settings=[
                types.SafetySetting(
                 category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
                 threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH,
                )
            ],
        ),
    )
    
    async def main():
        # Create a new session
        session_service = InMemorySessionService()
        session = await session_service.create_session(
            app_name="test-app",
            user_id="test-user",
            session_id="test-session",
    
        )
        print(f"Created session: {session.id}")
    
        runner = Runner(agent=pim_agent, session_service=session_service,app_name="test-app")
    
        new_message = types.Content(role="user", parts=[types.Part(text="What is 2 + 2?")])
        async for event in runner.run_async(
            new_message=new_message,
            user_id="test-user",
            session_id="test-session",
        ):
            print(f"\n\n\n\n{'='*100}\nresponse: {event.content.parts[0].text}\n\n\n\n{'='*100}")
    
    if __name__ == "__main__":
        asyncio.run(main())
    
    

    Response:

    ====================================================================================================
    response: 2 + 2 = 4.
    
    
    
    ====================================================================================================
    
  3. added
    core[Component] This issue is related to the core interface and implementation
    request clarification[Status] The maintainer need clarification or more information from the author
    and removed
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Sep 28, 2026
  4. SaeeSaadat commented on Sep 28, 2026

    @SaeeSaadat
    Author

    @llalitkumarrr Hi. did you use VertexAI authentication? Or API KEY? It works fine with API KEY but not with VertexAI.

  5. llalitkumarrr commented on Sep 28, 2026

    @llalitkumarrr
    Collaborator

    Hi @SaeeSaadat, We used VertexAI for this reproduction.

  6. self-assigned this
    on Oct 26, 2026
  7. GWeale commented on Oct 26, 2026

    @GWeale
    Collaborator

    hi @SaeeSaadat, thanks for sticking with this, and sorry about the earlier confusion: our first repro didn't set service_tier, which is why we missed it. vertex reads the tier from request headers and rejects the body value that google-genai sends. since adk just forwards service_tier straight to google-genai, the fix needs to happen over in googleapis/python-genai#2847. in the meantime, you can work around it by setting X-Vertex-AI-LLM-Request-Type: shared and X-Vertex-AI-LLM-Shared-Request-Type: priority in generate_content_config.http_options.headers. i'll close this issue so we can keep the tracking in one place.

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

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions