Skip to content

fix(graph): use SDK in-process ASGI transport for thread metadata writes#493

Merged
blove merged 2 commits into
mainfrom
claude/fix-in-process-sdk-client
May 20, 2026
Merged

fix(graph): use SDK in-process ASGI transport for thread metadata writes#493
blove merged 2 commits into
mainfrom
claude/fix-in-process-sdk-client

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 20, 2026

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') whenever LANGGRAPH_API_URL was unset, then HTTP-calling back into the runtime. In local dev this accidentally works because langgraph dev listens on 2024. On the prod runtime container the server is on a different port — every title write threw ConnectError, the bare except swallowed it, every prod thread showed "Untitled."

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. From the SDK docstring:

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:

  • 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 @traceable instrumentation stays. After merge + deploy, a probe should produce a LangSmith run with outputs.wrote_title: "<title slice>" instead of the ConnectError.

Test plan

  • Both graphs compile + import (from src.graph import graph)
  • CI green
  • After merge + deploy: probe → LangSmith run shows wrote_title, /api/threads/<id>.metadata.title populated, sidenav row shows the title (not "Untitled")
  • If the verification probe still fails, the @Traceable output will tell us what changed

Trail

🤖 Generated with Claude Code

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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview, Comment May 20, 2026 10:09pm

Request Review

@blove blove enabled auto-merge (squash) May 20, 2026 22:04
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>
@blove blove merged commit ce038e6 into main May 20, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant