Skip to content

feat: Add LangGraph integration#80

Merged
rapids-bot[bot] merged 17 commits into
NVIDIA:mainfrom
dagardner-nv:david-lg-int-p3
May 12, 2026
Merged

feat: Add LangGraph integration#80
rapids-bot[bot] merged 17 commits into
NVIDIA:mainfrom
dagardner-nv:david-lg-int-p3

Conversation

@dagardner-nv
Copy link
Copy Markdown
Contributor

@dagardner-nv dagardner-nv commented May 11, 2026

Overview

  • Builds on top of existing LangChain callbacks
  • Adds new langgraph extra
  • Minor adjustments to existing LangChain callbacks to accommodate LangGraph subclass
  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

Where should the reviewer start?

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Closes #

Summary by CodeRabbit

  • New Features

    • Added LangGraph integration as an optional langgraph extra and exposed middleware/callbacks for NeMo Flow observability.
  • Bug Fixes

    • Use callback-provided scope names when available.
    • Execute callbacks inline to preserve correct scope push/pop ordering.
  • Documentation

    • Added a LangGraph integration guide with setup, examples, and usage notes.
  • Tests

    • Added unit and integration tests validating LangGraph interoperability and lifecycle events.

Review Change Stack

…angchain

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv self-assigned this May 11, 2026
@dagardner-nv dagardner-nv added feat lang:python PR changes/introduces Python code labels May 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Walkthrough

Adds a LangGraph integration package and README, implements a LangGraph-to-NeMo Flow callback handler with JSON-safe serialization and mark emission, updates the LangChain callback handler to run inline and improve name resolution, updates packaging extras to add langgraph, and adds unit and integration tests for both integrations.

Changes

LangGraph Integration and Enhancement

Layer / File(s) Summary
Dependency and package structure
pyproject.toml, python/nemo_flow/integrations/langgraph/__init__.py, python/nemo_flow/integrations/langgraph/README.md
Added langgraph optional dependency extra (adds nemo-flow[langchain] and langgraph>=1.1.10,<2.0.0) and updated langchain-nvidia to use nemo-flow[langchain]. Added LangGraph package entrypoint exposing NemoFlowCallbackHandler and NemoFlowMiddleware, plus a README with setup and usage examples.
LangChain callback improvements
python/nemo_flow/integrations/langchain/callbacks.py, python/tests/integrations/langchain/test_callbacks.py
Set run_inline = True on NemoFlowCallbackHandler to preserve correct scope ordering and changed on_chain_start to prefer kwargs.get("name") before falling back to serialized.get("name"). Added/updated tests verifying inline behavior and callback-provided scope naming and cleaned up test signatures.
LangGraph callback handler implementation
python/nemo_flow/integrations/langgraph/callbacks.py
Implemented NemoFlowCallbackHandler for LangGraph lifecycle events: _json_safe() serializer, _interrupt_to_payload() extractor, on_interrupt() and on_resume() that emit NeMo Flow marks, and _emit_graph_mark() that calls nemo_flow.scope.event(...) with safe exception logging.
LangGraph integration test suite
python/tests/integrations/langgraph/test_langgraph_integration.py
Added tests defining a typed State and sync/async increment nodes, fixtures that compile the graph, a subscriber that records emitted nemo_flow.Events, tests asserting handler type compatibility, expected scope lifecycle event ordering for sync/async runs, and mark emission/serialization for interrupt/resume callbacks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title follows Conventional Commits format with 'feat' type and clear imperative summary under 72 characters.
Description check ✅ Passed PR description includes Overview section with required checkboxes marked, but Details and reviewer-start sections lack substantive content.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size:M PR is medium label May 11, 2026
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@willkill07 willkill07 added Feature a new feature and removed feat labels May 12, 2026
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv marked this pull request as ready for review May 12, 2026 16:15
@dagardner-nv dagardner-nv requested review from a team as code owners May 12, 2026 16:15
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/tests/integrations/langgraph/test_langgraph_integration.py`:
- Around line 92-116: The test_graph_callbacks currently runs the async path by
calling asyncio.run() inside a synchronous test; split this into two tests: keep
the existing synchronous path as test_sync_graph_callbacks using sync_graph and
graph.invoke(..., config={"callbacks":[NemoFlowCallbackHandler()]}), and add a
new async test test_async_graph_callbacks marked with `@pytest.mark.asyncio` that
uses async_graph and awaits async_graph.ainvoke(...,
config={"callbacks":[NemoFlowCallbackHandler()]}), preserving the same scope
context and assertions (result == {"value": 2"} and
events_to_strings(subscribed_events) == expected_events) and remove the
asyncio.run usage.
- Around line 40-48: In _build_graph replace the unnecessary cast by passing the
TypedDict type directly to StateGraph: remove cast(Any, State) and call
StateGraph(State); update the constructor call in _build_graph (which registers
nodes "increment" with aincrement/increment, adds edges START -> "increment" and
"increment" -> END, then calls builder.compile()) so it uses StateGraph(State)
instead of StateGraph(cast(Any, State)).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: a9f73762-e9fb-41ad-aaf6-fe8a4933de90

📥 Commits

Reviewing files that changed from the base of the PR and between 33860d9 and 47a87d1.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • pyproject.toml
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: License Diff / Run
  • GitHub Check: Python / Test (linux-arm64)
  • GitHub Check: Python / Test (windows-arm64)
  • GitHub Check: Python / Test (macos-arm64)
  • GitHub Check: Python / Test (linux-amd64)
  • GitHub Check: Documentation / Build
  • GitHub Check: Python / Test (windows-amd64)
🧰 Additional context used
📓 Path-based instructions (28)
**/*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Format changed Python wrapper and test files with uv run ruff format python

**/*.py: Use Ruff with rule sets E, F, W, I for Python linting
Use Ruff formatter for Python code with line length 120 and double quotes
Use ty for Python type checking
Use snake_case naming convention for Python code
Include SPDX license headers in all Python source files using Python comment syntax

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use SONAR_IGNORE_START / SONAR_IGNORE_END markers only for documented false positives that cannot be resolved in code; keep ignored blocks small, add explanatory comments, and require reviewer sign-off

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
python/nemo_flow/**/*.py

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Python API implementations and wrappers

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
**/*.{md,markdown,py,sh,bash,js,ts,java,cpp,go,rust}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep package names, repo references, and build commands current in documentation

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep stable user-facing wrappers at scripts/ root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash,js,ts,example}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Example commands must match current package names and paths

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{integrations,integration,*-integration}/**

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

**/{integrations,integration,*-integration}/**: Keep NeMo Flow optional in framework integrations
Preserve the framework's original behavior when NeMo Flow is absent
Wrap tool and LLM paths at the correct framework boundary
Integration pattern must follow docs/integrate-frameworks/adding-scopes.md

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
{docs/**,examples/**,crates/adaptive/**,python/nemo_flow/**,go/nemo_flow/**,**/{example,component}.{ts,tsx,js,rs,py,go}}

📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)

Any new adaptive component kind must have documentation, examples, and binding coverage across all supported languages

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
**/*.{js,ts,tsx,jsx,py,rs,go,java,c,cpp,h,cc,cxx,cs,rb,php,swift,kt}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changed files must be formatted with the language-native formatter

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
python/**/*.py

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

python/**/*.py: If Python language surface changed, always run Python test target even when Rust core did not change
For Python changes, use uv run ruff format python to format Python files

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{py,js,ts,tsx,go,rs,md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Format changed files with the language-native formatter before the final lint/test pass

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,js,ts,tsx,go}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

During iteration, prefer uv run pre-commit run --files <changed files...> for targeted validation

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
python/nemo_flow/**/*

⚙️ CodeRabbit configuration file

python/nemo_flow/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.

Files:

  • python/nemo_flow/integrations/langgraph/__init__.py
  • python/nemo_flow/integrations/langgraph/README.md
  • python/nemo_flow/integrations/langchain/callbacks.py
  • python/nemo_flow/integrations/langgraph/callbacks.py
**/*.{md,rst,html,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

**/*.{md,rst,html,txt}: Always spell NVIDIA in all caps. Do not use Nvidia, nvidia, nVidia, nVIDIA, or NV.
Use an NVIDIA before a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol after NVIDIA when referring to the company.
Use trademark symbols with product names only when the document type or legal guidance requires them.
Verify official capitalization, spacing, and hyphenation for product names.
Precede NVIDIA product names with NVIDIA on first mention when it is natural and accurate.
Do not rewrite product names for grammar or title-case rules.
Preserve third-party product names according to the owner's spelling.
Include the company name and full model qualifier on first use when it helps identify the model.
Preserve the official capitalization and punctuation of model names.
Use shorter family names only after the full name is established.
Spell out a term on first use and put the acronym in parentheses unless the acronym is widely understood by the intended audience.
Use the acronym on later mentions after it has been defined.
For long documents, reintroduce the full term if readers might lose context.
Form plurals of acronyms with s, not an apostrophe, such as GPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such as CPU, GPU, PC, API, and UI usually do not need to be spelled out for developer audiences.

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.{md,rst,html}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

Link the first mention of a product name when the destination helps the reader.

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.{md,rst,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

**/*.{md,rst,txt}: Spell NVIDIA in all caps. Do not use Nvidia, nvidia, or NV.
Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text. Avoid raw URLs and weak anchors such as 'here' or 'read more.'
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative steps. Keep steps parallel and split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English.
Use can for possibility and reserve may for permission.
Use after for temporal relationships instead of once.
Prefer refer to over see when the wording points readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical documentation.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values.
Use numerals for 10 or greater and include commas in thousands.
Do not add trademark symbols to learning-oriented documentation unless the source, platform, or legal guidance explicitly requires them.
Do not add trademark symbols to NeMo Flow learning documentation by default.
Do not rewrite API names, package names, command flags, or code literals for style reasons.

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.{md,markdown,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)

**/*.{md,markdown,rst}: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Use monospace formatting for code elements, commands, parameters, package names, and expressions
Use monospace formatting for directories, file names, and paths
Use angle brackets inside monospace for variables inside paths, such as /home/<username>/.login
Use quotation marks for error messages and strings in documentation
Use bold formatting for UI buttons, menus, fields, and labels in documentation
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use in documentation
Use italics for publication titles in documentation
Use plain text formatting for keyboard shortcuts in documentation
Prefer [NVIDIA/NeMo](link) format for GitHub repository references over generic phrases like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text in documentation
Avoid generic link anchors such as 'here,' 'this page,' and 'read more' in documentation
Include the acronym in link text if a linked term includes an acronym
Do not link long sentences or multiple sentences in documentation
Avoid links that pull readers away from a procedure unles...

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.{html,md}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license headers in HTML and Markdown files using HTML comment syntax

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/README.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update relevant crate or package README when that surface changed

Relevant package or crate README.md files must be updated when examples or binding guidance changes

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Run Markdown link checking via lychee for README.md, CONTRIBUTING.md, and docs/ through pre-commit hooks

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.{md,txt,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

**/*.{md,txt,rst}: Ensure commands, package names, file paths, and APIs in documentation are correct and not stale; flag incorrect or outdated information as blocking issues
Ensure examples and procedures in documentation will execute successfully with current APIs and commands
Use consistent user-facing terminology throughout documentation that matches current repo terminology
Capitalize NVIDIA correctly in all documentation and public-facing text
Format code, commands, paths, and filenames as inline code (monospace) in documentation
Use descriptive anchor text for links instead of bare URLs or weak labels like 'here' in documentation
Prefer active voice, present tense, short sentences, and plain English in documentation
Structure documentation procedures as imperative steps that are easy to scan and not too long for a single sequence
Prefer 'after' instead of 'once' for temporal references in documentation
Use 'can' instead of 'may' when describing possibility (rather than permission) in documentation
Avoid ambiguous numeric dates and ordinal dates in documentation body text

Files:

  • python/nemo_flow/integrations/langgraph/README.md
{README.md,docs/index.md,**/README.md}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Update entry-point documentation (README.md, docs/index.md, package READMEs, binding-level source READMEs) whenever public behavior changes

Files:

  • python/nemo_flow/integrations/langgraph/README.md
**/*.toml

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license headers in TOML files using TOML comment syntax

Files:

  • pyproject.toml
{Cargo.toml,setup.py,setup.cfg,pyproject.toml,go.mod,go.sum,package.json,package-lock.json,yarn.lock,pom.xml,*.gradle}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update repository manifest files (Cargo.toml, setup.py, go.mod, package.json, etc.) with new package/crate names during rename operations

Files:

  • pyproject.toml
{Cargo.toml,pyproject.toml,go/nemo_flow/go.mod,package.json,package-lock.json,crates/node/package.json}

📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)

Maintain consistent package names, import paths, and module names across Rust, Python, Go, Node, and WebAssembly workspaces in NeMo Flow

Files:

  • pyproject.toml
**/test_*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Run focused pytest first when you know the affected area using pytest -k "<pattern>"

Files:

  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • python/tests/integrations/langchain/test_callbacks.py
  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{tests,test}/**/*{integration,smoke}*.py

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Relevant integration tests or smoke path must pass before contribution

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
🪛 Ruff (0.15.12)
python/nemo_flow/integrations/langgraph/callbacks.py

[warning] 20-20: Dynamically typed expressions (typing.Any) are disallowed in value

(ANN401)


[warning] 22-25: Use contextlib.suppress(Exception) instead of try-except-pass

Replace try-except-pass with with contextlib.suppress(Exception): ...

(SIM105)


[error] 24-25: try-except-pass detected, consider logging the exception

(S110)


[warning] 24-24: Do not catch blind exception: Exception

(BLE001)


[warning] 36-36: Dynamically typed expressions (typing.Any) are disallowed in interrupt

(ANN401)


[warning] 53-53: Dynamically typed expressions (typing.Any) are disallowed in on_interrupt

(ANN401)


[warning] 67-67: Dynamically typed expressions (typing.Any) are disallowed in on_resume

(ANN401)


[warning] 87-87: Do not catch blind exception: Exception

(BLE001)

python/tests/integrations/langgraph/test_langgraph_integration.py

[warning] 40-40: Boolean-typed positional argument in function definition

(FBT001)


[warning] 40-40: Boolean default positional argument in function definition

(FBT002)


[warning] 94-94: Boolean-typed positional argument in function definition

(FBT001)

🔇 Additional comments (14)
python/nemo_flow/integrations/langchain/callbacks.py (2)

25-26: Inline callback execution is correctly enforced.

run_inline = True is the right change to preserve deterministic scope push/pop ordering.


45-49: Chain name precedence is implemented correctly.

Preferring callback-provided name and then falling back to serialized data is a safe and backward-compatible resolution order.

python/tests/integrations/langchain/test_callbacks.py (4)

52-53: Good targeted assertion for inline callback behavior.

This directly guards the expected handler configuration for async callback manager execution semantics.


75-86: Callback-provided name precedence is well covered.

This test precisely validates the new name override path introduced in on_chain_start.


55-159: Scope lifecycle coverage is solid.

Start/end/error mapping, parent propagation, noop-on-missing-start, and fallback naming are all exercised with clear assertions.


164-198: No-op and exception-swallowing paths are appropriately tested.

These tests protect the integration’s non-intrusive behavior when NeMo Flow is unavailable or push/pop fails.

pyproject.toml (1)

82-90: LGTM! Proper dependency composition.

The self-referencing extras pattern (nemo-flow[langchain]) correctly composes dependencies and ensures that installing the langgraph extra also brings in the required LangChain integration.

python/nemo_flow/integrations/langgraph/__init__.py (1)

1-12: LGTM! Correct re-export structure.

The package correctly re-exports NemoFlowMiddleware from the LangChain integration and the new NemoFlowCallbackHandler from the local callbacks module.

python/nemo_flow/integrations/langgraph/callbacks.py (3)

20-33: LGTM! Conservative JSON serialization.

The try-except pattern here is intentional for defensive serialization—if _prepare_outputs fails, the function falls back to basic type checking and repr(). This ensures mark emission never fails due to serialization issues.


53-78: LGTM! Correct lifecycle hook implementation.

Both on_interrupt and on_resume properly extract event metadata, emit NeMo Flow marks via _emit_graph_mark, and return None as required by the GraphCallbackHandler protocol.


80-88: LGTM! Appropriate error resilience.

Catching broad Exception here is correct—mark emission should never crash the LangGraph workflow. Debug logging preserves troubleshooting capability while maintaining resilience.

python/tests/integrations/langgraph/test_langgraph_integration.py (2)

61-71: LGTM! Proper fixture cleanup.

The fixture correctly registers a uniquely-named event subscriber and ensures cleanup via yield, preventing test pollution.


119-161: LGTM! Comprehensive lifecycle validation.

The test thoroughly validates interrupt/resume mark emission, serialization of interrupt payloads, checkpoint namespace preservation, and integration metadata tagging.

python/nemo_flow/integrations/langgraph/README.md (1)

60-68: ⚡ Quick win

The create_agent function exists in langchain.agents and is part of the public LangChain API, as confirmed by official LangChain documentation. The code shown is correct and requires no changes.

			> Likely an incorrect or invalid review comment.

Comment thread python/tests/integrations/langgraph/test_langgraph_integration.py
Comment thread python/tests/integrations/langgraph/test_langgraph_integration.py Outdated
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/tests/integrations/langgraph/test_langgraph_integration.py`:
- Around line 52-60: The tests request a non-existent fixture name "graph";
update the two test functions to request the correct explicit fixtures: change
the parameter of test_sync(...) to use sync_graph (the fixture function named
sync_graph that returns CompiledStateGraph with use_async=False) and change the
parameter of test_async(...) to use async_graph (the fixture async_graph that
returns CompiledStateGraph with use_async=True); ensure the function signatures
for test_sync and test_async reference these exact fixture names so pytest can
resolve them.
- Around line 94-103: Tests test_sync and test_async request a non-existent
fixture named graph causing FixtureLookupError; update their parameter names to
use the existing fixtures sync_graph and async_graph respectively (or add a
parametrized graph fixture if preferred), and change the Test class __init__
method to define _expected_events as a class attribute (move the list out of
__init__ into a class-level _expected_events) so test discovery doesn't
instantiate the test class incorrectly; update references to _expected_events
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: c14582ed-5ffc-47c4-91b6-f21a25f3610c

📥 Commits

Reviewing files that changed from the base of the PR and between 47a87d1 and 8317c85.

📒 Files selected for processing (1)
  • python/tests/integrations/langgraph/test_langgraph_integration.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (13)
**/*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Format changed Python wrapper and test files with uv run ruff format python

**/*.py: Use Ruff with rule sets E, F, W, I for Python linting
Use Ruff formatter for Python code with line length 120 and double quotes
Use ty for Python type checking
Use snake_case naming convention for Python code
Include SPDX license headers in all Python source files using Python comment syntax

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/test_*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Run focused pytest first when you know the affected area using pytest -k "<pattern>"

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use SONAR_IGNORE_START / SONAR_IGNORE_END markers only for documented false positives that cannot be resolved in code; keep ignored blocks small, add explanatory comments, and require reviewer sign-off

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash,js,ts,java,cpp,go,rust}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep package names, repo references, and build commands current in documentation

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep stable user-facing wrappers at scripts/ root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash,js,ts,example}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Example commands must match current package names and paths

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{integrations,integration,*-integration}/**

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

**/{integrations,integration,*-integration}/**: Keep NeMo Flow optional in framework integrations
Preserve the framework's original behavior when NeMo Flow is absent
Wrap tool and LLM paths at the correct framework boundary
Integration pattern must follow docs/integrate-frameworks/adding-scopes.md

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{tests,test}/**/*{integration,smoke}*.py

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Relevant integration tests or smoke path must pass before contribution

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{js,ts,tsx,jsx,py,rs,go,java,c,cpp,h,cc,cxx,cs,rb,php,swift,kt}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changed files must be formatted with the language-native formatter

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
python/**/*.py

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

python/**/*.py: If Python language surface changed, always run Python test target even when Rust core did not change
For Python changes, use uv run ruff format python to format Python files

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{py,js,ts,tsx,go,rs,md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Format changed files with the language-native formatter before the final lint/test pass

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,js,ts,tsx,go}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

During iteration, prefer uv run pre-commit run --files <changed files...> for targeted validation

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
🪛 Ruff (0.15.12)
python/tests/integrations/langgraph/test_langgraph_integration.py

[warning] 40-40: Boolean-typed positional argument in function definition

(FBT001)


[warning] 40-40: Boolean default positional argument in function definition

(FBT002)


[warning] 94-94: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)

Comment thread python/tests/integrations/langgraph/test_langgraph_integration.py
Comment thread python/tests/integrations/langgraph/test_langgraph_integration.py
Signed-off-by: David Gardner <dagardner@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/tests/integrations/langgraph/test_langgraph_integration.py`:
- Around line 115-124: The async test method test_async is defined as async def
but missing the pytest-asyncio marker, so add the `@pytest.mark.asyncio` decorator
immediately above the test_async definition and ensure pytest is imported in the
file; apply this to the test_async method that calls async_graph.ainvoke and
checks result/events (and adjust any existing imports to include pytest if not
present).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: b5725d12-c54b-4847-8763-f2ec0d7dc0bc

📥 Commits

Reviewing files that changed from the base of the PR and between 8317c85 and bdeb3bd.

📒 Files selected for processing (1)
  • python/tests/integrations/langgraph/test_langgraph_integration.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (13)
**/*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Format changed Python wrapper and test files with uv run ruff format python

**/*.py: Use Ruff with rule sets E, F, W, I for Python linting
Use Ruff formatter for Python code with line length 120 and double quotes
Use ty for Python type checking
Use snake_case naming convention for Python code
Include SPDX license headers in all Python source files using Python comment syntax

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/test_*.py

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Run focused pytest first when you know the affected area using pytest -k "<pattern>"

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use SONAR_IGNORE_START / SONAR_IGNORE_END markers only for documented false positives that cannot be resolved in code; keep ignored blocks small, add explanatory comments, and require reviewer sign-off

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash,js,ts,java,cpp,go,rust}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep package names, repo references, and build commands current in documentation

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep stable user-facing wrappers at scripts/ root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{md,markdown,py,sh,bash,js,ts,example}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Example commands must match current package names and paths

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{integrations,integration,*-integration}/**

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

**/{integrations,integration,*-integration}/**: Keep NeMo Flow optional in framework integrations
Preserve the framework's original behavior when NeMo Flow is absent
Wrap tool and LLM paths at the correct framework boundary
Integration pattern must follow docs/integrate-frameworks/adding-scopes.md

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/{tests,test}/**/*{integration,smoke}*.py

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Relevant integration tests or smoke path must pass before contribution

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{js,ts,tsx,jsx,py,rs,go,java,c,cpp,h,cc,cxx,cs,rb,php,swift,kt}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changed files must be formatted with the language-native formatter

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
python/**/*.py

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

python/**/*.py: If Python language surface changed, always run Python test target even when Rust core did not change
For Python changes, use uv run ruff format python to format Python files

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{py,js,ts,tsx,go,rs,md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Format changed files with the language-native formatter before the final lint/test pass

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
**/*.{rs,py,js,ts,tsx,go}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

During iteration, prefer uv run pre-commit run --files <changed files...> for targeted validation

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • python/tests/integrations/langgraph/test_langgraph_integration.py
🪛 Ruff (0.15.12)
python/tests/integrations/langgraph/test_langgraph_integration.py

[warning] 40-40: Boolean-typed positional argument in function definition

(FBT001)


[warning] 40-40: Boolean default positional argument in function definition

(FBT002)


[warning] 94-94: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)

🔇 Additional comments (5)
python/tests/integrations/langgraph/test_langgraph_integration.py (5)

40-49: Remove the unnecessary cast(Any, State).

StateGraph accepts TypedDict directly per LangGraph documentation. The cast to Any defeats type checking without runtime benefit.

 def _build_graph(use_async: bool = False) -> CompiledStateGraph:
-    # The cast here avoids a ty linting error
-    builder = StateGraph(cast(Any, State))
+    builder = StateGraph(State)  # type: ignore[arg-type]

If ty complains, a targeted type ignore is cleaner than casting away all type information.


93-102: Test class __init__ will cause AttributeError at runtime.

Pytest doesn't call __init__ when instantiating test classes for collection. When test_sync or test_async runs, self._expected_events won't exist. Convert to a class attribute:

 class TestGraphCallbacks:
-    def __init__(self):
-        self._expected_events = [
-            "scope.start.request",
-            "scope.start.LangGraph",
-            "scope.start.increment",
-            "scope.end.increment",
-            "scope.end.LangGraph",
-            "scope.end.request",
-        ]
+    _expected_events = [
+        "scope.start.request",
+        "scope.start.LangGraph",
+        "scope.start.increment",
+        "scope.end.increment",
+        "scope.end.LangGraph",
+        "scope.end.request",
+    ]

169-169: 💤 Low value

Missing newline at end of file.

Add a trailing newline to comply with POSIX conventions and avoid diff noise.


1-5: LGTM!

SPDX license header and module docstring are correctly in place.


127-169: LGTM!

The interrupt/resume lifecycle test properly validates mark event emission, payload serialization, and metadata. Good coverage of the callback handler's interrupt/resume behavior.

Comment thread python/tests/integrations/langgraph/test_langgraph_integration.py
Copy link
Copy Markdown
Collaborator

@Salonijain27 Salonijain27 left a comment

Choose a reason for hiding this comment

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

Approved from a dependency point of view

@dagardner-nv
Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot rapids-bot Bot merged commit 9e5b672 into NVIDIA:main May 12, 2026
31 checks passed
AjayThorve added a commit to AjayThorve/NeMo-Flow that referenced this pull request May 12, 2026
Pulls in:
- feat: Add LangGraph integration (NVIDIA#80)
- docs(openclaw): add plugin guide (NVIDIA#79)
- ci: gate package jobs on package path changes (NVIDIA#85)
@willkill07 willkill07 added this to the 0.2.0 milestone May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature a new feature lang:python PR changes/introduces Python code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants