fix(graph): use SDK in-process ASGI transport for thread metadata writes#493
Merged
Conversation
Root cause of the production "all threads Untitled" bug (diagnosed via PR #492's @Traceable wrapper): error_type: ConnectError error_message: All connection attempts failed sdk_url: http://localhost:2024 The Python helper was calling get_client(url='http://localhost:2024') when LANGGRAPH_API_URL was unset, then trying to HTTP-call back into the runtime. In local dev this accidentally works because `langgraph dev` listens on 2024. In prod the runtime is on a different port, so every title write threw ConnectError and the bare except swallowed it. Fix: pass `url=os.environ.get("LANGGRAPH_API_URL")` (no fallback). When None, the SDK uses its in-process ASGI transport — the canonical path for graph-to-server self-calls. Docstring excerpt: > If `None`, the client first attempts an in-process connection via > ASGI transport. ... This only works if the client is used from > within the Agent server. Applies to both: - examples/chat/python (canonical demo, where the bug surfaced) - cockpit/chat/threads/python (same anti-pattern, would've failed on prod for the same reason) The @Traceable instrumentation from #492 stays — it'll confirm the fix on the next prod probe by surfacing `wrote_title: <slice>` in the LangSmith run output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR #474 added a generate_title node to c-a2ui mirroring the examples/chat pattern — including the same broken localhost:2024 fallback. Same fix: pass `url=None` (via unset env) so the SDK uses its in-process ASGI transport. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause (diagnosed via PR #492's @Traceable wrapper)
{ "error_type": "ConnectError", "error_message": "All connection attempts failed", "sdk_url": "http://localhost:2024", "thread_id": "019e4768-143b-7f73-8da2-55c9657d478d" }The Python helper was calling
get_client(url='http://localhost:2024')wheneverLANGGRAPH_API_URLwas unset, then HTTP-calling back into the runtime. In local dev this accidentally works becauselanggraph devlistens on 2024. On the prod runtime container the server is on a different port — every title write threwConnectError, the bareexceptswallowed it, every prod thread showed "Untitled."Fix
Pass
url=os.environ.get("LANGGRAPH_API_URL")(no fallback). WhenNone, the SDK uses its in-process ASGI transport — the canonical path for graph-to-server self-calls. From the SDK docstring:Applies to:
examples/chat/python(the demo where the bug surfaced)cockpit/chat/threads/python(same anti-pattern; would've failed on prod for the same reason)Verification
PR #492's
@traceableinstrumentation stays. After merge + deploy, a probe should produce a LangSmith run withoutputs.wrote_title: "<title slice>"instead of the ConnectError.Test plan
from src.graph import graph)wrote_title,/api/threads/<id>.metadata.titlepopulated, sidenav row shows the title (not "Untitled")Trail
🤖 Generated with Claude Code