fix: lazy-import AsyncPostgresSaver to fix ops-worker/gumbo startup crash (ModuleNotFoundError langgraph.checkpoint.postgres)
Build Gumbo Agent / build-gumbo-agent (push) Failing after 10s Details

This commit is contained in:
Antigravity 2026-05-29 14:05:19 -04:00
parent 43697759c8
commit 571ae057ad
3 changed files with 11 additions and 2 deletions

View File

@ -7,8 +7,8 @@ from typing import TypedDict
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_openai import ChatOpenAI
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
from langgraph.graph import END, StateGraph
# AsyncPostgresSaver imported lazily in run_gumbo() to avoid startup crash
from gumbo.mcp_fs import fetch_text_via_mcp
@ -53,6 +53,10 @@ def build_graph_builder() -> StateGraph:
async def run_gumbo(object_key: str, thread_id: str, conn_string: str) -> GumboState:
try:
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
except ImportError:
from langgraph_checkpoint_postgres.aio import AsyncPostgresSaver
builder = build_graph_builder()
async with AsyncPostgresSaver.from_conn_string(conn_string) as checkpointer:
await checkpointer.setup()

View File

@ -4,7 +4,7 @@ from typing import TypedDict
from langchain_core.messages import SystemMessage, HumanMessage
from langchain_openai import ChatOpenAI
from langgraph.graph import StateGraph, END
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
# AsyncPostgresSaver imported lazily below (only when conn_string is provided)
from ops_agent.tools import (
k8s_get_status, k8s_get_logs, k8s_restart_pod, k8s_scale_deployment,
@ -214,6 +214,10 @@ async def run_ops_graph(target_type: str, target_id: str, is_approved: bool = Fa
}
if conn_string:
try:
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
except ImportError:
from langgraph_checkpoint_postgres.aio import AsyncPostgresSaver
async with AsyncPostgresSaver.from_conn_string(conn_string) as checkpointer:
await checkpointer.setup()
graph = builder.compile(checkpointer=checkpointer)

View File

@ -1,4 +1,5 @@
langgraph>=0.2.0
langgraph-checkpoint-postgres>=2.0.0
langchain-core>=0.3.0
langchain-openai>=0.2.0
temporalio>=1.8.0