ADK + Vertex AI Agent Engine + CopilotKit - AG-UI Protocol Translation Issue

Hi Google ADK community,

I’m stuck on a production-blocking integration issue between Vertex AI Agent Engine (ADK Python agent) and CopilotKit v1.50 (AG-UI protocol), and I’m hoping for guidance on the correct architecture.

TL;DR

My app works perfectly on localhost, but fails completely when deployed to Vercel + Vertex AI Agent Engine. I’m stuck in what feels like “Adapter Hell” between CopilotKit’s strict AG-UI validation and Vertex’s REST-based Agent Engine APIs. I’ve been blocked for 48+ hours despite trying every integration path I can find.

Setup:

Backend

  • Google ADK Python agent

  • Deployed to Vertex AI Agent Engine

  • Auth: OAuth2 via service account (working)

  • API shape: createSession, /sessions/{id}:query

Frontend

  • Next.js 14 (App Router)

  • CopilotKit v1.50.1

  • Deployed on Vercel

Resources

Core Problem

CopilotKit speaks AG-UI / JSON-RPC, sending requests like:

{ "method": "agent/connect", "params": {...} }

Vertex AI Agent Engine expects REST calls:

  • POST :createSession

  • POST /sessions/{id}:query

There is no native AG-UI endpoint exposed by Agent Engine, so I attempted to build a translation layer in route.ts. This works locally but fails immediately in production due to validation, protocol, and runtime mismatches.


What I’ve Tried (Exhaustive)

  • Custom Agent Class
    Implemented VertexAIAgent with setMessages / setState / execute
    → Failed due to CopilotKit v1.50 interface/type mismatches.

  • Service Adapter Pattern
    Built VertexAIServiceAdapter.process()
    → Never invoked (ignored by CopilotKit runtime).

  • HttpAgent (@ag-ui**/client)**
    Used new HttpAgent({ url, headers })
    → Blocked because headers can’t be async (OAuth token refresh).

  • Manual Request Handler
    Bypassed CopilotKit runtime and parsed requests manually
    → Messages empty / request shape incorrect.

  • AG-UI Protocol Handler
    Implemented agent/connect and agent.run JSON-RPC handlers
    → 400 errors from method name mismatches.

  • LangChainAdapter Hack
    Masqueraded as OpenAI (provider: "openai") with custom chainFn
    → Failed validation/runtime.

  • Custom Streaming Adapter
    Implemented CopilotServiceAdapter and manually streamed via eventSource.stream()
    → Not recognized by runtime.

  • Observability Config Workaround
    Added dummy hooks to satisfy type checker
    → No runtime effect.

  • ag_ui_adk Wrapper
    Works locally with FastAPI
    → Cannot deploy to Agent Engine (pickle / thread lock errors).

Why I’m Blocked(probably)

  • CopilotKit v1.50 enforces strict AG-UI wiring

  • Vertex AI Agent Engine does not expose AG-UI

  • There’s no documented or supported way to:

    • Disable CopilotKit’s “magic” auto-wiring

    • Or expose Agent Engine via AG-UI in production

Key Ask?

  1. Is there an official or recommended way to expose a Vertex AI Agent Engine deployment via AG-UI?

  2. Should I be using a different deployment target ?

  3. Is there a working example of a raw / minimal AG-UI adapter for CopilotKit v1.50 that allows full protocol control?

  4. Has anyone successfully deployed a production middleware translator between AG-UI and Vertex Agent Engine?

I found Daniel Zamora’s article very helpful…but it relies on local FastAPI, not a managed Agent Engine deployment, which is where everything breaks.

I’m clearly missing a canonical integration path here. Any guidance—architecture-level or concrete examples—would be a huge lifesaver. I’m happy to adapt my stack if Agent Engine is simply not meant to be consumed this way.

Thank you so much for your time and help :folded_hands:

1 Like

I guess you will have to run your backend using FastAPI, and wrap your root agent with ADKAgent (via the ag-ui-sdk adapter). You might also want to check out the CopilotKit docs and Dojo examples

That said, there’s likely a trade-off between easy UI integration and managing session/memory via the agent engine.

Have you found a workaround or a cleaner way to handle this?

You’re not crazy Anand …this isn’t u messing something up, it’s just a mismatch between how these 2 systems work.

CopilotKit expects an AG-UI / JSON-RPC endpoint, but Vertex Agent Engine only exposes REST. There’s no native way :smiling_face_with_tear: to connect them directly, which is why everything works locally but breaks in production. Right now, there’s no official way to expose Agent Engine as AG-UI.

The practical way to make this work is to put a middleware service in between (FastAPI, Node, etc.) that it takes AG-UI requests from CopilotKit , translates them into Vertex REST calls, handles auth + session and sends responses back in AG-UI format.

Also, Vercel alone usually won’t cut it here because of the runtime + auth limitations & you’ll want something like Cloud Run for that middle layer.

this isn’t a missing config, it’s just not a natively supported integration yet

1 Like