Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughAdds 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 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
plugin/langchain/lib/tracing/LangGraphTracer.ts (1)
8-9: Consider restoringreadonlymodifier if mutation is not required.The logger field was changed from
private readonlyto public without readonly. While public visibility may be needed for external access or dependency injection, removingreadonlyallows the logger to be reassigned at runtime, which could affect stability.Unless logger mutation is specifically required, consider restoring the
readonlymodifier:@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 becauseLangGraphTracerdefaults tolangGraphTracer, 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
📒 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-decoratormatches 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).
There was a problem hiding this comment.
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
executionfield is positioned beforenamein the SSE test (lines 51-53) but afternamein the streamable (lines 84-86) and factory (lines 116-118) tests. Whileassert.deepStrictEqualdoesn'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
📒 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. TheEggHttpMCPClientimplementation delegateslistTools()to the parentHttpMCPClientclass (from the external@eggjs/mcp-clientpackage) without filtering or modifying the response. Theexecutionfield itself is provided by the@modelcontextprotocol/sdkwhen 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.
4a3b8a1 to
0f0d502
Compare
0f0d502 to
fe727f0
Compare
There was a problem hiding this comment.
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 sharedexpectedAddToolobject 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
📒 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 forexecution.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.
Checklist
npm testpassesAffected core subsystem(s)
Description of change
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.