From b711cf1ef7a76cc36d38ea5d7bdf8058e0449f09 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Wed, 20 May 2026 14:21:27 -0700 Subject: [PATCH] debug(graph): surface _maybe_write_thread_title failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The frontend debug PR (#486) confirmed refresh() runs and resolves with 50 threads on demo.threadplane.ai/embed — so the empty-looking sidenav is actually 50 rows all labeled "Untitled" because metadata.title is missing on every prod thread. The Python title write is failing silently. Suspected cause: examples/chat/python/src/graph.py:99 falls back to LANGGRAPH_API_URL='http://localhost:2024' when the env var is unset inside the LangGraph Platform runtime container — which it almost certainly is. The get_client() call points at a port that doesn't exist in the container, threads.update() throws, the bare `except Exception: return` swallows it. Replace the bare swallow with a print(..., flush=True) in both graphs so the next prod run surfaces the actual error in LangGraph Platform logs. Once we see the error we can fix the URL/auth. Same anti-pattern, same fix as PR #486 (frontend adapter). Co-Authored-By: Claude Opus 4.7 (1M context) --- cockpit/chat/threads/python/src/graph.py | 13 +++++++++++-- examples/chat/python/src/graph.py | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cockpit/chat/threads/python/src/graph.py b/cockpit/chat/threads/python/src/graph.py index 89dd7c8df..02db531e2 100644 --- a/cockpit/chat/threads/python/src/graph.py +++ b/cockpit/chat/threads/python/src/graph.py @@ -67,8 +67,17 @@ async def generate_title(state: MessagesState, config) -> dict: title = (response.content or "").strip().strip('"').strip("'")[:80] if title: await client.threads.update(thread_id, metadata={"thread_title": title}) - except Exception: # noqa: BLE001 — title is a UX nicety; never block - pass + except Exception as e: # noqa: BLE001 — title is a UX nicety; never block + # Don't break the run, but DO log. A bare pass has hidden a prod + # bug in the sibling examples/chat graph where the title write was + # failing silently on every thread (LANGGRAPH_API_URL fallback to + # localhost:2024 inside the runtime container). Surface here to + # catch the same class of failure early. + print( + f"[generate_title] failed for thread {thread_id}: " + f"{type(e).__name__}: {e}", + flush=True, + ) return {} diff --git a/examples/chat/python/src/graph.py b/examples/chat/python/src/graph.py index 699509bac..fe40962c1 100644 --- a/examples/chat/python/src/graph.py +++ b/examples/chat/python/src/graph.py @@ -125,8 +125,17 @@ async def _maybe_write_thread_title(state: "State", config: RunnableConfig) -> N thread_id, metadata={"title": title}, ) - except Exception: - # Title write must never break the run. Swallow. + except Exception as e: # noqa: BLE001 — title is a UX nicety; never block + # Don't break the run, but DO log. A bare swallow has hidden a prod + # bug where the title write was failing silently on every thread + # (LANGGRAPH_API_URL fallback to localhost:2024 inside the runtime + # container). Print to stdout so it surfaces in LangGraph Platform + # logs without needing a logger to be configured. + print( + f"[_maybe_write_thread_title] failed for thread {thread_id}: " + f"{type(e).__name__}: {e}", + flush=True, + ) return