Repository navigation
refactor(ai.common): consolidate node helpers; drop dead code - #924
Conversation
|
No description provided. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughCentralizes duplicated helpers into a new ai.common.utils package (safe_str, tool-arg normalization/validators, config parsing, and agent helpers), updates agents and tool nodes to import those utilities, removes corresponding implementations from rocketlib and many legacy nodes/library modules, and adds unit tests for the new utilities. ChangesShared utilities and tests
Migrate consumers to shared utilities
Error-formatting and docstring edits
Remove legacy nodes/library and SAC HTTP code
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
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 `@nodes/src/nodes/agent_crewai/crewai_base.py`:
- Around line 62-66: Update the class docstring to reflect the actual import
source for safe_str: change the reference that says "safe_str is imported from
ai.common.agent" to "safe_str is imported from nodes.library.utils" (or simply
remove the outdated module name), leaving the rest of the note about
`_escape_braces` and `_merge_instructions` being `@staticmethod`s intact so
subclasses can call `self._escape_braces(...)` and
`self._merge_instructions(...)`; the relevant docstring is in the CrewAI base
class in `crewai_base.py`.
In `@nodes/src/nodes/library/agent_tools.py`:
- Around line 97-100: The current except fallback sets AIMessage = HumanMessage
= SystemMessage = ToolMessage = object which makes isinstance(...,
SystemMessage) succeed for any object; instead define a unique sentinel class
(e.g., _MissingLangchainMessage) in the same scope and assign AIMessage =
HumanMessage = SystemMessage = ToolMessage = _MissingLangchainMessage so that
isinstance checks against SystemMessage/HumanMessage/AIMessage/ToolMessage
correctly fail when langchain_core is absent; update the try/except block that
imports AIMessage, HumanMessage, SystemMessage, ToolMessage to declare the
sentinel class and use it as the fallback target.
🪄 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: Pro
Run ID: 9ea757cc-f924-42c7-96df-d7a7ae1cce89
📒 Files selected for processing (32)
nodes/src/nodes/agent_crewai/crewai_agent/agent.pynodes/src/nodes/agent_crewai/crewai_base.pynodes/src/nodes/agent_crewai/crewai_manager/manager.pynodes/src/nodes/agent_deepagent/deepagent.pynodes/src/nodes/agent_langchain/langchain.pynodes/src/nodes/agent_rocketride/planner.pynodes/src/nodes/agent_rocketride/rocketride_agent.pynodes/src/nodes/index_search/IGlobal.pynodes/src/nodes/library/agent_tools.pynodes/src/nodes/library/config_utils.pynodes/src/nodes/library/tool_args.pynodes/src/nodes/library/utils.pynodes/src/nodes/qdrant/IGlobal.pynodes/src/nodes/search_exa/exa_search.pynodes/src/nodes/tool_bland_ai/IGlobal.pynodes/src/nodes/tool_exa_search/IInstance.pynodes/src/nodes/tool_filesystem/IInstance.pynodes/src/nodes/tool_firecrawl/IInstance.pynodes/src/nodes/tool_git/IGlobal.pynodes/src/nodes/tool_git/IInstance.pynodes/src/nodes/tool_github/IInstance.pynodes/src/nodes/tool_http_request/IGlobal.pynodes/src/nodes/tool_pipe/IInstance.pynodes/src/nodes/vectordb_postgres/IGlobal.pynodes/src/nodes/weaviate/IGlobal.pynodes/test/library/__init__.pynodes/test/library/test_agent_tools.pynodes/test/library/test_config_utils.pynodes/test/library/test_tool_args.pynodes/test/library/test_utils.pypackages/server/engine-lib/rocketlib-python/lib/rocketlib/__init__.pypackages/server/engine-lib/rocketlib-python/lib/rocketlib/filters.py
💤 Files with no reviewable changes (1)
- packages/server/engine-lib/rocketlib-python/lib/rocketlib/init.py
04441bf to
5efe919
Compare
There was a problem hiding this comment.
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 `@packages/ai/src/ai/common/utils/tool_args.py`:
- Around line 116-124: The pydantic unwrapping in normalize_tool_input (the
unwrap_pydantic branch that calls input_obj.model_dump() and input_obj.dict())
can raise and break the best-effort normalization; wrap each call in a small
try/except that catches exceptions from model_dump() and dict(), preserves the
original input_obj on failure, and (optionally) logs or silences the error so
normalization continues; update the code around the model_dump and as_dict calls
to try the unwrap, fall back to leaving input_obj unchanged on any exception,
and continue processing.
In `@packages/ai/tests/ai/common/utils/test_tool_args.py`:
- Line 10: The docstring incorrectly lists require_bool among the validators;
update the test file docstring to remove require_bool so it only mentions
require_str, require_int, and require_dict (the actual validators imported and
tested). Locate the top-level comment in the tests referencing require_str /
require_int / require_bool and edit it to drop require_bool, leaving
require_dict (and any surrounding punctuation) correct.
🪄 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: Pro
Run ID: a022a632-41b8-47ab-9c5f-8f21e61ae7a3
📒 Files selected for processing (72)
nodes/src/nodes/agent_crewai/crewai_agent/agent.pynodes/src/nodes/agent_crewai/crewai_base.pynodes/src/nodes/agent_crewai/crewai_manager/manager.pynodes/src/nodes/agent_deepagent/deepagent.pynodes/src/nodes/agent_langchain/langchain.pynodes/src/nodes/agent_rocketride/planner.pynodes/src/nodes/agent_rocketride/rocketride_agent.pynodes/src/nodes/index_search/IGlobal.pynodes/src/nodes/library/__init__.pynodes/src/nodes/library/englib_handler/__init__.pynodes/src/nodes/library/helpers/FolderTracker.pynodes/src/nodes/library/image/embed.pynodes/src/nodes/library/msgraph/__init__.pynodes/src/nodes/library/msgraph/application_permissions.pynodes/src/nodes/library/permissions/MSPermissions.pynodes/src/nodes/library/permissions/PermissionSet.pynodes/src/nodes/library/permissions/__init__.pynodes/src/nodes/library/permissions/utils.pynodes/src/nodes/library/sac_requests/__init__.pynodes/src/nodes/library/sac_requests/adapters/__init__.pynodes/src/nodes/library/sac_requests/adapters/timeout.pynodes/src/nodes/library/sac_requests/constants/__init__.pynodes/src/nodes/library/sac_requests/constants/chars.pynodes/src/nodes/library/sac_requests/constants/defaults.pynodes/src/nodes/library/sac_requests/constants/general.pynodes/src/nodes/library/sac_requests/constants/messages.pynodes/src/nodes/library/sac_requests/context/__init__.pynodes/src/nodes/library/sac_requests/context/config.pynodes/src/nodes/library/sac_requests/context/endpoint.pynodes/src/nodes/library/sac_requests/context/headers.pynodes/src/nodes/library/sac_requests/context/py.typednodes/src/nodes/library/sac_requests/context/request.pynodes/src/nodes/library/sac_requests/context/session.pynodes/src/nodes/library/sac_requests/context/timeout.pynodes/src/nodes/library/sac_requests/context/url.pynodes/src/nodes/library/sac_requests/exceptions/__init__.pynodes/src/nodes/library/sac_requests/exceptions/base.pynodes/src/nodes/library/sac_requests/exceptions/connection.pynodes/src/nodes/library/sac_requests/py.typednodes/src/nodes/library/sac_requests/utils/__init__.pynodes/src/nodes/library/sac_requests/utils/general.pynodes/src/nodes/library/sac_requests/utils/py.typednodes/src/nodes/library/sac_requests/utils/validators.pynodes/src/nodes/library/sac_requests/wrapper.pynodes/src/nodes/qdrant/IGlobal.pynodes/src/nodes/search_exa/exa_search.pynodes/src/nodes/tool_bland_ai/IGlobal.pynodes/src/nodes/tool_exa_search/IInstance.pynodes/src/nodes/tool_filesystem/IInstance.pynodes/src/nodes/tool_firecrawl/IInstance.pynodes/src/nodes/tool_git/IGlobal.pynodes/src/nodes/tool_git/IInstance.pynodes/src/nodes/tool_github/IInstance.pynodes/src/nodes/tool_http_request/IGlobal.pynodes/src/nodes/tool_pipe/IInstance.pynodes/src/nodes/vectordb_postgres/IGlobal.pynodes/src/nodes/weaviate/IGlobal.pypackages/ai/src/ai/common/agent/__init__.pypackages/ai/src/ai/common/agent/_internal/utils.pypackages/ai/src/ai/common/agent/agent.pypackages/ai/src/ai/common/utils/__init__.pypackages/ai/src/ai/common/utils/agent_tools.pypackages/ai/src/ai/common/utils/config_utils.pypackages/ai/src/ai/common/utils/string_utils.pypackages/ai/src/ai/common/utils/tool_args.pypackages/ai/tests/ai/common/utils/__init__.pypackages/ai/tests/ai/common/utils/test_agent_tools.pypackages/ai/tests/ai/common/utils/test_config_utils.pypackages/ai/tests/ai/common/utils/test_tool_args.pypackages/ai/tests/ai/common/utils/test_utils.pypackages/server/engine-lib/rocketlib-python/lib/rocketlib/__init__.pypackages/server/engine-lib/rocketlib-python/lib/rocketlib/filters.py
💤 Files with no reviewable changes (34)
- nodes/src/nodes/library/sac_requests/adapters/init.py
- nodes/src/nodes/library/sac_requests/constants/messages.py
- nodes/src/nodes/library/permissions/init.py
- nodes/src/nodes/library/sac_requests/context/url.py
- nodes/src/nodes/library/sac_requests/constants/defaults.py
- nodes/src/nodes/library/sac_requests/context/endpoint.py
- nodes/src/nodes/library/msgraph/init.py
- nodes/src/nodes/library/sac_requests/context/headers.py
- nodes/src/nodes/library/sac_requests/exceptions/base.py
- nodes/src/nodes/library/sac_requests/context/session.py
- nodes/src/nodes/library/sac_requests/constants/chars.py
- nodes/src/nodes/library/init.py
- nodes/src/nodes/library/sac_requests/context/request.py
- nodes/src/nodes/library/sac_requests/exceptions/init.py
- nodes/src/nodes/library/sac_requests/constants/init.py
- nodes/src/nodes/library/msgraph/application_permissions.py
- nodes/src/nodes/library/sac_requests/context/config.py
- nodes/src/nodes/library/sac_requests/utils/validators.py
- nodes/src/nodes/library/sac_requests/context/timeout.py
- nodes/src/nodes/library/sac_requests/adapters/timeout.py
- nodes/src/nodes/library/sac_requests/utils/init.py
- nodes/src/nodes/library/sac_requests/context/init.py
- nodes/src/nodes/library/image/embed.py
- nodes/src/nodes/library/sac_requests/wrapper.py
- nodes/src/nodes/library/sac_requests/utils/general.py
- packages/server/engine-lib/rocketlib-python/lib/rocketlib/init.py
- nodes/src/nodes/library/sac_requests/exceptions/connection.py
- nodes/src/nodes/library/helpers/FolderTracker.py
- nodes/src/nodes/library/sac_requests/init.py
- nodes/src/nodes/library/sac_requests/constants/general.py
- nodes/src/nodes/library/permissions/MSPermissions.py
- nodes/src/nodes/library/permissions/PermissionSet.py
- nodes/src/nodes/library/englib_handler/init.py
- nodes/src/nodes/library/permissions/utils.py
|
Actionable comments posted: 0 |
d37811c to
63f6fb1
Compare
anandray
left a comment
There was a problem hiding this comment.
LGTM — this is a high-value refactor. 2,294 net-deleted lines (including ~3000 lines of dead nodes/library/ tree wholesale), single-source canonical safe_str in ai.common.utils.string_utils, and a 683-line test suite landing alongside ~819 lines of new source means coverage tracks the new surface.
Spot-checked the deletes: msgraph/application_permissions.py (-219), sac_requests/context/request.py (-621), permissions/MSPermissions.py (-346) all carry zero in-repo imports per the body's claim.
One safety check worth doing before merge: a quick grep against the downstream rocketride-saas repo for from nodes.library / import nodes.library. The "no consumers" claim is scoped to this repo; if a downstream pipeline or service imports from the deleted tree, it'd break silently on next deploy.
One coordination note: this PR includes the same check-externals.yml change as #1032. Whichever lands first, the other will need a trivial rebase. Probably easiest to land #1032 (after its CR fixes), then rebase this onto the result.
f43eb26 to
564a17f
Compare
…ride-org#924) * refactor(ai.common, nodes): rebase * fix: coderabbit issues * refactor(ai.common, nodes): rebase
Summary
ai.common.utilspackage re-exports shared helpers from submodulesstring_utils(safe_str),tool_args(require_*/optional_*/normalize_tool_input/validate_tool_input_schema/require_dict),config_utils(parse_bool/config_int), andagent_tools(normalize_bound_tools/langchain_messages_to_transcript).__init__.pyis a pure re-export module — callers importfrom ai.common.utils import <name>.nodes/library/tree deleted in full. Its only useful contents (tool_args,config_utils,agent_tools,safe_str) moved toai.common.utils; the rest (helpers,image,permissions,msgraph,sac_requests,englib_handler) was dead code with no external callers.safe_stris now defined in exactly one place (ai.common.utils.string_utils) — the previous duplicate inai.common.agent._internal.utilsis removed; agent internals import fromai.common.utilslike everyone else.normalize_invocation_payload(and its nested_best_effort_pydantic_dump) removed fromai.common.agent._internal.utils— zero call sites in the repo; the live counterpart isai.common.utils.normalize_tool_inputwith 45 callers and 22 test cases. Driver-specific_format_error(qdrant / weaviate / vectordb_postgres / index_search) intentionally stays inside each owning node.Type
refactor
Testing
packages/ai/tests/ai/common/utils/test_*.py—tool_args,config_utils,agent_tools,utils; cross-check guard for the strict-vs-loose bool split)./builder testpassesChecklist
Linked Issue
Fixes #923
Summary by CodeRabbit