Skip to content

馃Л fix: Normalize GraphInterrupt Langfuse Traces - #348

Merged
danny-avila merged 2 commits into
mainfrom
danny-avila/fix-prod-observability
Jul 29, 2026
Merged

danny-avila merged 2 commits into
mainfrom
danny-avila/fix-prod-observability

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

I normalized expected LangGraph human-in-the-loop interruptions in Langfuse so ask_user_question pauses no longer inflate production error telemetry.

  • Classify nested GraphInterrupt and NodeInterrupt chain callbacks as successful control-flow endings.
  • Close nested interrupted tool observations through handleToolEnd with a sanitized {"controlFlow":"GraphInterrupt"} marker.
  • Preserve genuine nested failures and defensively retain root-level error handling for synthetic callback sequences.
  • Add a real StateGraph + MemorySaver pause/resume regression covering callback ancestry, checkpointed interrupt payloads, resumed tool output, sanitized telemetry, and balanced spans.
  • Add focused coverage for nested chain/tool interruptions, NodeInterrupt, null errors, and genuine failures.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

I exercised the real ask_user_question pause/resume path and verified the callback classification directly.

  • npm test -- --runTestsByPath src/specs/langfuse-callbacks.test.ts --runInBand
  • npx eslint src/langfuse.ts src/specs/langfuse-callbacks.test.ts
  • npx prettier --check src/langfuse.ts src/specs/langfuse-callbacks.test.ts
  • npx tsc --noEmit
  • npm run build
  • git diff --check

Test Configuration

  • Node.js 24-compatible local toolchain
  • @langchain/langgraph 1.4.6
  • @librechat/agents 3.3.4 development checkout

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective
  • Local unit tests pass with my changes

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8d8f7606a

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/specs/langfuse-callbacks.test.ts Outdated
description: 'suspends to collect a human answer',
schema: z.object({}).passthrough(),
}
) as unknown as StructuredToolInterface;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve type checking for the HITL tool

Replace this as unknown as StructuredToolInterface cast with a correctly typed tool or adapter. The double assertion suppresses structural checking in the real HITL integration test, so changes that make the generated tool incompatible with ToolNode can be accepted rather than diagnosed at the construction site; the repository guidance explicitly prohibits this assertion pattern.

AGENTS.md reference: AGENTS.md:L49-L49

Useful? React with 馃憤聽/ 馃憥.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1e3a10a. The generated structured tool now flows directly into ToolNode without the prohibited double assertion, so TypeScript retains structural compatibility checking. Verified with 21/21 focused tests, tsc, ESLint, Prettier, and the import-sort check.

Comment thread src/langfuse.ts Outdated
@@ -1,5 +1,5 @@
import { CallbackHandler } from '@langfuse/langchain';
import { isParentCommand } from '@langchain/langgraph';
import { isGraphInterrupt, isParentCommand } from '@langchain/langgraph';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Sort the changed imports before merging

Running node scripts/sort-imports.ts --check src/langfuse.ts src/specs/langfuse-callbacks.test.ts reports that both changed files need sorting, so the repository's import-order check fails for this commit. Reorder the package and type imports using the project's sorter before merging.

AGENTS.md reference: AGENTS.md:L63-L69

Useful? React with 馃憤聽/ 馃憥.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1e3a10a. Ran the repository sorter on both changed files and pinned it with node scripts/sort-imports.ts --check src/langfuse.ts src/specs/langfuse-callbacks.test.ts; the focused test, tsc, ESLint, Prettier, and diff checks also pass.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 1e3a10a4f4

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila marked this pull request as ready for review July 29, 2026 02:10
@danny-avila
danny-avila merged commit bae3b1e into main Jul 29, 2026
13 checks passed
danny-avila added a commit that referenced this pull request Jul 29, 2026
Feature release: cooperative mid-generation stream preemption (#335),
jest module mapping for @langchain/mistralai (#343), predecessor
prefill handoff cue for bare direct-edge successors on Claude (#346),
plus #337, #348, #350.
@danny-avila danny-avila mentioned this pull request Jul 29, 2026
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