Skip to content

fix: update trace logger check#372

Merged
akitaSummer merged 2 commits intomasterfrom
fix/update_trace_logger
Dec 6, 2025
Merged

fix: update trace logger check#372
akitaSummer merged 2 commits intomasterfrom
fix/update_trace_logger

Conversation

@akitaSummer
Copy link
Contributor

@akitaSummer akitaSummer commented Dec 5, 2025

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features

    • Expanded LangChain/LangGraph integration with additional public exports for graph building, tracing, state compilation, object binding, and config utilities.
    • Made the graph tracer available with public access.
  • Bug Fixes

    • API tool responses in tests now include execution.taskSupport set to "forbidden".
  • Chores

    • Added public decorator support for the LangChain framework and added its package dependency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a LangChain decorator re-export and dependency; extends plugin langchain public exports; changes tracer lookup from class-based to name-based and relaxes tracer matching to prototype checks; makes tracer logger non-private; and updates test expectations to include execution.taskSupport = 'forbidden'.

Changes

Cohort / File(s) Summary
Core langchain surface & dependency
core/tegg/langchain.ts, core/tegg/package.json
New module re-exporting all from @eggjs/tegg-langchain-decorator; adds dependency "@eggjs/tegg-langchain-decorator": "^3.64.2".
Public API barrel exports
plugin/langchain/index.ts
Added re-exports for BoundModelObjectHook, QualifierUtil, CompiledStateGraphObject, CompiledStateGraphProto, GraphBuildHook, GraphLoadUnitHook, GraphObjectHook, GraphPrototypeHook, LangGraphTracer.
Factory lookup change
plugin/langchain/lib/graph/CompiledStateGraphObject.ts
Replaced class-based container retrieval with name-based lookup: getOrCreateEggObjectFromClazz(LangGraphTracer)getOrCreateEggObjectFromName('langGraphTracer').
Prototype-based matching
plugin/langchain/lib/graph/GraphBuildHook.ts
Relaxed tracer proto matching from strict equality to allow prototype-chain checks (`LangGraphTracer.isPrototypeOf(proto)
Tracer proto config & field visibility
plugin/langchain/lib/tracing/LangGraphTracer.ts
Added AccessLevel import and set @SingletonProto({ accessLevel: AccessLevel.PUBLIC }); changed logger from private readonly logger: Logger; to logger: Logger;.
Test expectations updated
plugin/mcp-client/test/mcpclient.test.ts
Test expectations expanded to include execution.taskSupport = 'forbidden' in tool objects for SSE, streamable, and factory cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay attention to:
    • Consistency of the 'langGraphTracer' container name across the codebase.
    • Prototype-based matching potentially matching unintended classes.
    • Impact of making logger public/mutable in LangGraphTracer.
    • Test expectation changes and their alignment with runtime behavior.

Suggested reviewers

  • killagu
  • gxkl

Poem

🐇 A tracer hops from name, not class,
Re-exports tucked into the mass,
Prototype checks, a gentler test,
Logger freed to do its best,
The rabbit nods — these changes pass!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: update trace logger check' refers to changes in GraphBuildHook.ts and LangGraphTracer.ts related to tracing, but the changeset includes significant additions across multiple files (new module exports, dependency additions, new public API exports), making the title only partially representative of the main changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/update_trace_logger

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @akitaSummer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the integration of LangChain tracing within the Egg.js framework by addressing how the LangGraphTracer is identified and instantiated. It enhances the lookup mechanism to be more flexible and ensures proper recognition of inherited tracer classes. Additionally, the changes expand the public API of the LangChain plugin and incorporate a new decorator package, contributing to a more robust and extensible tracing system.

Highlights

  • Refactored LangGraphTracer Lookup: The mechanism for retrieving LangGraphTracer instances within the Egg.js container has been updated from a class-based lookup to a name-based lookup, improving flexibility.
  • Improved Tracer Inheritance Handling: The GraphBuildHook now correctly identifies LangGraphTracer instances, including those that are subclasses, by utilizing isPrototypeOf for a more robust check.
  • Expanded LangChain Plugin Exports: Several new modules related to bound models, qualifiers, graph components, and tracing have been added to the public exports of the plugin/langchain/index.ts file.
  • New LangChain Decorator Dependency: A new dependency, @eggjs/tegg-langchain-decorator, has been introduced and its contents are now re-exported through core/tegg/langchain.ts.
  • Logger Accessibility Adjustment: The logger property within LangGraphTracer has been changed from private and readonly to public, potentially allowing for greater configurability or testing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the logic for handling the LangGraphTracer. The changes to use getOrCreateEggObjectFromName and isPrototypeOf for checking the tracer's class are solid improvements that increase the robustness of the code. My main feedback is regarding the LangGraphTracer class, where the logger property's visibility was changed from private readonly to public. This change weakens encapsulation, and I've recommended reverting it to maintain better code quality and prevent potential future issues.

Copy link

@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

🧹 Nitpick comments (2)
plugin/langchain/lib/tracing/LangGraphTracer.ts (1)

8-9: Consider restoring readonly modifier if mutation is not required.

The logger field was changed from private readonly to public without readonly. While public visibility may be needed for external access or dependency injection, removing readonly allows the logger to be reassigned at runtime, which could affect stability.

Unless logger mutation is specifically required, consider restoring the readonly modifier:

  @Inject()
- logger: Logger;
+ readonly logger: Logger;
plugin/langchain/lib/graph/CompiledStateGraphObject.ts (1)

40-40: Extract the hardcoded tracer name to a constant to avoid brittleness and enable refactor safety.

The lookup of 'langGraphTracer' relies on a hardcoded string that depends on the default camelCase naming convention of @SingletonProto(). While this works because LangGraphTracer defaults to langGraphTracer, the lack of an explicit name parameter makes this fragile:

  • Typos in the string won't be caught until runtime
  • Refactoring the class name won't automatically update the lookup
  • The dependency on naming convention is implicit and undocumented

Define a constant for the tracer name and use it explicitly in the @SingletonProto() decorator:

// In LangGraphTracer.ts
export const LANG_GRAPH_TRACER_NAME = 'langGraphTracer';

@SingletonProto({ name: LANG_GRAPH_TRACER_NAME })
export class LangGraphTracer extends BaseTracer {
  // ...
}

// In CompiledStateGraphObject.ts
const langGraphTraceObj = await EggContainerFactory.getOrCreateEggObjectFromName(LANG_GRAPH_TRACER_NAME);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2684270 and 5c343e4.

📒 Files selected for processing (6)
  • core/tegg/langchain.ts (1 hunks)
  • core/tegg/package.json (1 hunks)
  • plugin/langchain/index.ts (1 hunks)
  • plugin/langchain/lib/graph/CompiledStateGraphObject.ts (1 hunks)
  • plugin/langchain/lib/graph/GraphBuildHook.ts (1 hunks)
  • plugin/langchain/lib/tracing/LangGraphTracer.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
plugin/langchain/lib/graph/GraphBuildHook.ts (1)
core/metadata/src/model/ProtoDescriptor/ClassProtoDescriptor.ts (1)
  • ClassProtoDescriptor (10-38)
plugin/langchain/lib/tracing/LangGraphTracer.ts (1)
core/tegg/index.ts (1)
  • Logger (11-11)
plugin/langchain/lib/graph/CompiledStateGraphObject.ts (1)
core/runtime/src/factory/EggContainerFactory.ts (1)
  • EggContainerFactory (18-88)
⏰ 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). (8)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Analyze (typescript)
🔇 Additional comments (3)
core/tegg/package.json (1)

51-51: LGTM! Dependency version is consistent.

The new dependency on @eggjs/tegg-langchain-decorator matches the version scheme of other tegg packages and enables the LangChain functionality introduced in this PR.

core/tegg/langchain.ts (1)

1-1: LGTM! Standard barrel export pattern.

Clean re-export of the LangChain decorator package to make it accessible through the core tegg module.

plugin/langchain/index.ts (1)

2-10: Confirm that exposing internal modules is intentional.

This PR expands the public API surface by exporting 9 internal modules, including hooks (BoundModelObjectHook, GraphBuildHook, etc.) and implementation classes (CompiledStateGraphObject, CompiledStateGraphProto).

Exposing internal modules increases the maintenance burden and commits to backward compatibility. Please confirm:

  • Are these modules intended for public consumption?
  • Is there documentation for how external code should use these exports?
  • Have you considered the long-term maintenance implications?

Note: GraphBuildHook (line 6) currently has a critical bug in its prototype check that should be fixed before public exposure (see separate comment).

Copy link

@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: 0

🧹 Nitpick comments (1)
plugin/mcp-client/test/mcpclient.test.ts (1)

51-53: Consider standardizing property order across test cases.

The execution field is positioned before name in the SSE test (lines 51-53) but after name in the streamable (lines 84-86) and factory (lines 116-118) tests. While assert.deepStrictEqual doesn't enforce property order, consistent ordering improves test readability and maintainability.

If the different property orders reflect actual API response variations between SSE, streamable, and factory implementations, consider adding a comment explaining this difference.

Also applies to: 83-86, 115-118

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c343e4 and 4a3b8a1.

📒 Files selected for processing (1)
  • plugin/mcp-client/test/mcpclient.test.ts (3 hunks)
⏰ 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). (9)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Socket Security: Project Report
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (18)
🔇 Additional comments (1)
plugin/mcp-client/test/mcpclient.test.ts (1)

51-53: No implementation changes needed — the execution field is correctly provided by the MCP SDK.

The test expectations for execution.taskSupport: 'forbidden' are already being met. The EggHttpMCPClient implementation delegates listTools() to the parent HttpMCPClient class (from the external @eggjs/mcp-client package) without filtering or modifying the response. The execution field itself is provided by the @modelcontextprotocol/sdk when tools are registered on the MCP server. The fixture servers and implementation are correctly integrated with the SDK, and the tests confirm the field is returned as expected.

Likely an incorrect or invalid review comment.

@akitaSummer akitaSummer force-pushed the fix/update_trace_logger branch from 4a3b8a1 to 0f0d502 Compare December 5, 2025 11:56
@akitaSummer akitaSummer force-pushed the fix/update_trace_logger branch from 0f0d502 to fe727f0 Compare December 5, 2025 12:15
Copy link

@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: 0

🧹 Nitpick comments (1)
plugin/mcp-client/test/mcpclient.test.ts (1)

116-118: Factory tool expectation consistent; consider sharing common tool shape.

The factory test now also asserts execution.taskSupport: 'forbidden', keeping all three endpoints in sync. As a small optional cleanup, you could extract a shared expectedAddTool object used across these three tests to avoid repetition and keep them in lockstep if the shape changes again.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f0d502 and fe727f0.

📒 Files selected for processing (3)
  • plugin/langchain/lib/graph/GraphBuildHook.ts (1 hunks)
  • plugin/langchain/lib/tracing/LangGraphTracer.ts (1 hunks)
  • plugin/mcp-client/test/mcpclient.test.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugin/langchain/lib/tracing/LangGraphTracer.ts
  • plugin/langchain/lib/graph/GraphBuildHook.ts
⏰ 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). (6)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-ubuntu (16)
🔇 Additional comments (2)
plugin/mcp-client/test/mcpclient.test.ts (2)

51-53: SSE tool expectation updated correctly for execution.taskSupport.

The added execution: { taskSupport: 'forbidden' } matches the new response shape and keeps the assertion explicit and readable. No issues here.


84-86: Streamable tool expectation aligned with new execution metadata.

Same execution.taskSupport: 'forbidden' check added here; consistent with the SSE test and the documented shape of the MCP client response. Looks good.

Copy link
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

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

LGTM

@akitaSummer akitaSummer merged commit b974762 into master Dec 6, 2025
12 checks passed
@akitaSummer akitaSummer deleted the fix/update_trace_logger branch December 6, 2025 02:53
@coderabbitai coderabbitai bot mentioned this pull request Dec 8, 2025
4 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2026
4 tasks
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.

2 participants