Repository navigation
fix(langchain): keep LangGraph pauses and handoffs out of error spans - #508
Merged
Merged
Conversation
LangGraph's interrupt() and Command.PARENT handoffs throw GraphBubbleUp control-flow signals through handleChainError. The tracer exported those runs as ERROR spans with an exception event, and the interrupt() status message carried the interrupt payload. Treat bubble-ups as successful runs, mark interrupt() pauses with langgraph.interrupt (as the Python integration does), and keep real errors as errors. Declare @opentelemetry/core, which the tracer imports: under Yarn PnP and pnpm without hoisting the package failed to load. Pass the README's OpenAI key as apiKey, since ChatOpenAI 1.x ignores openAIApiKey. CI runs the LangGraph contract on LangGraph 0.2.74, 0.4.10, 1.0.0 and 1.6.0, and loads the packed package with strict pnpm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Follow-up to #383. That PR made
@traceai/langchainthe supported TypeScript LangGraph integration. Three problems remained, all older than #383.What was wrong
interrupt()andCommand.PARENThandoffs were exported as ERROR spans. LangGraph pauses and hands off by throwingGraphBubbleUpsignals (GraphInterrupt,ParentCommand) throughhandleChainError. The tracer treated anyrun.erroras a failure. With@langchain/langgraph1.6.0 and@langchain/core1.3.2, a human-in-the-loop pause produced an ERRORask_humanspan. Its exception event and status message contained the interrupt payload. A handoff made theroute, subgraph andsubspans ERROR even though the graph returned normally. The Python integration already treats these signals as non-errors.@opentelemetry/corewas imported but not declared.tracer.tsimportsisTracingSuppressedfrom it. With npm and the hoisting workspace this only worked because@traceai/fi-core's copy was hoisted. Under Yarn PnP and pnpm withhoist=false, bothrequire()andimportof@traceai/langchainfailed, so tracing never started.openAIApiKey.ChatOpenAI1.x ignores that alias at runtime and reads onlyapiKey,configuration.apiKeyorOPENAI_API_KEY.Changes
src/tracer.ts: an error withis_bubble_up === true, which is LangGraph's ownisGraphBubbleUpcheck, now ends the span OK, with no exception event and no status message. When onlyrun.erroris available, the tracer matches the LangGraph signal names instead. Without importing LangGraph, it now:GraphInterruptandNodeInterruptwithlanggraph.interrupt: trueand aninterruptevent, as Python does. The payload is never recorded.ParentCommandhandoffs unmarked.package.jsonandpnpm-lock.yaml: declare@opentelemetry/core@^2.0.1. This matches@traceai/fi-core, so it resolves to the same2.0.1the lock already has. The only lockfile change is the 3-line importer entry.apiKey, and the Features list gains one line on LangGraph pauses and handoffs.contract/readme.mjsnow rejectsopenAIApiKey.Tests
New
src/__tests__/bubbleUp.test.tscovers:run.error-only fallbackis_bubble_upare still errorsBefore the fix, 3 of these tests fail. The negative controls pass both before and after.
New
src/__tests__/dependencies.test.ts: every package imported by the shipped source must be listed independenciesorpeerDependencies. The workspace hoists everything, so only a static check can catch this in the repo. It fails before the fix by naming@opentelemetry/core.New
contract/langgraph.mjs, using real LangGraph, CJS and ESM, no network. It checks aninterrupt()pause and resume, aCommand.PARENThandoff from a subgraph, and a real node failure as a control. CI runs it with LangGraph 0.2.74 and 0.4.10 on core 0.3.80, and 1.0.0 and 1.6.0 on core 1.3.2.New CI step: install the packed tarballs with pnpm
hoist=false, thenrequireandimportthe package.Local results, all run with outbound network denied:
hoist=false, CJS and ESM: all pass. It failed before the fix.@langchain/openai1.8.0: passes.release_plan.py --checkandpnpm install --frozen-lockfilepass.pnpm run lintfor this package was already failing before this change, because ESLint 9 finds no flat config. CI does not run it.🤖 Generated with Claude Code