Skip to content

feat(middleware): @threadplane/middleware/langgraph — LangGraph.js client-tools middleware#667

Merged
blove merged 8 commits into
mainfrom
claude/middleware-js
Jun 16, 2026
Merged

feat(middleware): @threadplane/middleware/langgraph — LangGraph.js client-tools middleware#667
blove merged 8 commits into
mainfrom
claude/middleware-js

Conversation

@blove

@blove blove commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Plan B core (plan · spec). The TypeScript/LangGraph.js twin of the Python threadplane-middleware.

What's in

  • New Nx lib libs/middleware → npm @threadplane/middleware, imported as @threadplane/middleware/langgraph (vendor-first subpath). Built with @nx/js:tsc + tested with @nx/vitest (mirrors libs/telemetry); excluded from the Angular publishable lockstep group — independent cadence.
  • 1:1 mirror of the 7 Python functions: clientToolSpecs, clientToolNames, lastMessage, hasClientToolCall, hasServerToolCall, bindClientTools, routeAfterAgent (same semantics incl. the server-vs-client precedence rule and the serverToolNames parameter).
  • Two idiomatic LangGraph.js extras: clientToolsChannel() (an Annotation state fragment for the tools/client_tools channels) and clientToolsRouter() (a prebuilt conditional-edge factory).
  • @langchain/core + @langchain/langgraph are peer deps; no runtime deps.

Verification

  • 22 unit tests (mirror the Python suite case-for-case) + 1 in-process integration test that drives a real StateGraph with a scripted fake model through the full loop: bind → client-only tool call → route to END → append ToolMessage → re-invoke → final content. 23 total, all green.
  • nx lint + nx build green; the built package exposes the ./langgraph export with emitted .d.ts.

Follow-ups (separate, after merge): the examples/ag-ui/node demo server + live-LLM smoke, and the staged npm publish workflow.

🤖 Generated with Claude Code

@blove blove enabled auto-merge (squash) June 16, 2026 04:01
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview, Comment Jun 16, 2026 4:04am

Request Review

@blove blove merged commit 53bb646 into main Jun 16, 2026
3 checks passed
blove added a commit that referenced this pull request Jun 17, 2026
… retry budget (#667 regression) (#677)

@langchain/langgraph-sdk 1.9.x (bumped from 1.7.4 in #667) wraps every
connect attempt — including the initial run stream — in AsyncCaller's
p-retry (default 4 retries, exponential backoff ~15s) before throwing a
ConnectionError. A failed stream therefore no longer fails fast: the error
alert surfaces ~15-20s late instead of immediately, which broke
examples/chat e2e `error-handling` (15s assertion window) and degrades the
real UX of a dropped connection.

Production keeps the SDK's resilient default. Add a `clientOptions.maxRetries`
knob on `provideAgent` / `agent()` (threaded → FetchStreamTransport →
createLangGraphClient → SDK `callerOptions`). examples/chat reads a localStorage
flag (`THREADPLANE_E2E_MAX_RETRIES`) to opt into fail-fast (0 retries) under
test; the e2e sets it via addInitScript so the alert surfaces immediately.

- libs/langgraph: LangGraphClientOptions type + clientOptions on AgentOptions /
  AgentConfig; createLangGraphClient maps maxRetries → callerOptions.
- examples/chat: e2eClientOptions() helper (+ unit tests); DemoShell switches to
  factory-form provideAgent so the flag is read at injection time.
- api-docs regenerated for the new public surface.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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