Skip to content

How to Deploy a LangGraph Agent on GCP Agent Engine #3061

@HamzaAI9D

Description

@HamzaAI9D

Hello team,

I’ve been working on building agents with LangGraph, and they are running fine locally. Now I’d like to wrap them using the Google Agent Development Kit (ADK) or another supported method in order to host them directly on the GCP Agent Engine.

Here’s my use case:

I have already developed and deployed one agent successfully on the GCP Agent Engine.

I would like to extend this setup to host LangGraph-based agents (example below).

While one option is to package the agent in Docker and deploy it, I’m specifically looking for a way to host it natively on the Agent Engine via ADK.

For reference, here’s a dummy LangGraph agent I’d like to host:

`from typing import Annotated
from typing_extensions import TypedDict

from langchain_tavily import TavilySearch
from langchain_core.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import StateGraph, START
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode, tools_condition
from langgraph.types import interrupt

class State(TypedDict):
messages: Annotated[list, add_messages]

graph_builder = StateGraph(State)

@tool
def human_assistance(query: str) -> str:
"""Request assistance from a human."""
human_response = interrupt({"query": query})
return human_response["data"]

tool = TavilySearch(max_results=2)
tools = [tool, human_assistance]
llm_with_tools = llm.bind_tools(tools)

def chatbot(state: State):
message = llm_with_tools.invoke(state["messages"])
assert len(message.tool_calls) <= 1
return {"messages": [message]}

graph_builder.add_node("chatbot", chatbot)
tool_node = ToolNode(tools=tools)
graph_builder.add_node("tools", tool_node)

graph_builder.add_conditional_edges("chatbot", tools_condition)
graph_builder.add_edge("tools", "chatbot")
graph_builder.add_edge(START, "chatbot")
`

Metadata

Metadata

Assignees

Labels

agent engine[Component] This issue is related to Agent Engine deployment

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions