Add Oracle Integrations#6026
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds Oracle vector-search support and an Oracle embeddings provider: a new OracleVectorSearchTool with metadata filtering, index/ingest/search lifecycle, docs, and tests; plus an OracleEmbeddingFunction, OracleProvider types/factory overloads, and tests including integrations with Memory. ChangesOracle Vector Search Tool
Oracle Embedding Provider for RAG
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 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: 6
🤖 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 `@lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.md`:
- Around line 25-115: The README examples are missing imports for modules used
in the snippets; add the required imports (e.g., import os and import oracledb)
at the top of any snippet that uses os.environ or oracledb.create_pool, keeping
the existing from crewai_tools import (OracleVectorSearchConfig,
OracleVectorSearchQueryConfig, OracleVectorSearchTool) lines so
OracleVectorSearchTool, OracleVectorSearchConfig, OracleVectorSearchQueryConfig,
and any pool creation calls resolve correctly.
In
`@lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py`:
- Around line 551-585: vector_index_exists currently strips schema by using
.split(".")[-1] and _index_exists only filters on table_name, which can match
wrong rows for schema-qualified tables; update vector_index_exists to parse the
quoted schema/owner and table separately (use
_quote_identifier(self.oracle_config.table_name) then split on the first dot to
get owner and table parts) and pass both owner and table into _index_exists, and
update _index_exists to accept an optional owner parameter and include an AND
owner = :owner (or owner = :idx_owner) in the SQL when provided (ensure you
remove surrounding quotes consistently like index_name_no_quotes and
table_name_no_quotes and derive owner_no_quotes similarly) so the lookup filters
on owner, table_name and index_name to correctly detect schema-qualified
indexes.
- Around line 470-538: _embedded_text handling assumes embedding_function is
str->list[float]; update _embed_texts to accept both single-text callables and
batch-style callables (like the Oracle provider that accepts list[str] and
returns list[list[float]]). In the _embed_texts method, call
embedding_function(texts) first; if it raises a TypeError or returns a flat list
of floats for a single text, fall back to calling embedding_function per text
(e.g., [embedding_function(t) for t in texts]); if the result is a sequence
whose elements are sequences of floats and its length equals len(texts), return
it directly. Make this change in the _embed_texts implementation so it handles
embedding_function (and the Oracle embedding callable) correctly without
producing nested vectors.
- Around line 478-503: The _setup_oracle model_validator currently prompts the
user and attempts a runtime install when ORACLEDB_AVAILABLE is false; remove the
interactive click.confirm block and the subprocess "uv add" logic and instead
immediately raise a clear ImportError instructing the user to install oracledb.
Concretely, in _setup_oracle replace the click.confirm/import
subprocess/installed_oracledb flow with a simple try: import oracledb as
installed_oracledb except ImportError as exc: raise ImportError("The 'oracledb'
package is required to use OracleVectorSearchTool. Please install it with: uv
add oracledb") from exc, then set oracledb = installed_oracledb and
ORACLEDB_AVAILABLE = True (or simply raise the ImportError if you prefer not to
auto-import).
In `@lib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.py`:
- Around line 54-55: The code sets a session-level proxy via utl_http.set_proxy
when self._proxy is present but never resets it, so caller-managed connections
(self._owns_connection == False) can inherit that proxy; update the finally
block in the method that uses cursor.execute(...) (where self._proxy is set) to,
when self._proxy is truthy and self._owns_connection is False, execute a cleanup
call to reset the session proxy (utl_http.set_proxy(NULL)) before closing the
cursor and handle any cleanup errors without suppressing the original exception.
- Around line 49-52: OracleEmbeddingFunction.__call__ mutates the global driver
default self._oracledb.defaults.fetch_lobs and never restores it; capture the
current value before setting it (prev = self._oracledb.defaults.fetch_lobs), set
fetch_lobs = False for the call, and ensure you restore the original value in a
finally block so other Oracle operations aren’t affected. Locate the fetch_lobs
assignment and surrounding try block in OracleEmbeddingFunction.__call__ and
wrap the call logic with try/finally to reset self._oracledb.defaults.fetch_lobs
back to prev.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 99ab7555-20d5-4177-8c5c-1bf29adc620c
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
lib/crewai-tools/pyproject.tomllib/crewai-tools/src/crewai_tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.mdlib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/__init__.pylib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.pylib/crewai-tools/tests/tools/test_oracle_vector_search_tool.pylib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.pylib/crewai/src/crewai/rag/embeddings/factory.pylib/crewai/src/crewai/rag/embeddings/providers/oracle/__init__.pylib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.pylib/crewai/src/crewai/rag/embeddings/providers/oracle/oracle_provider.pylib/crewai/src/crewai/rag/embeddings/providers/oracle/types.pylib/crewai/src/crewai/rag/embeddings/types.pylib/crewai/tests/rag/embeddings/test_oracle_memory_integration.pylib/crewai/tests/rag/embeddings/test_oracle_provider.py
There was a problem hiding this comment.
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 `@lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py`:
- Around line 47-50: The test uses _embed_texts which relies on _embed_text
mapping "This unrelated text is about cooking pasta." to a zero vector, causing
undefined/flaky behavior when OracleVectorSearchTool is instantiated with
distance_strategy="COSINE" (embeddings are inserted as-is via add_texts and
scored with vector_distance in _run). Replace that specific fixture string in
both the single and batch tests with a different phrase that _embed_text maps to
a non-zero embedding so cosine distance behaves deterministically; update the
test inputs passed to OracleVectorSearchTool (where distance_strategy="COSINE")
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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b68cb4fd-ccaf-4df6-8531-63becf16b50c
📒 Files selected for processing (6)
lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.mdlib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.pylib/crewai-tools/tests/tools/test_oracle_vector_search_tool.pylib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.pylib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.pylib/crewai/tests/rag/embeddings/test_oracle_provider.py
✅ Files skipped from review due to trivial changes (1)
- lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.md
🚧 Files skipped from review as they are similar to previous changes (4)
- lib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.py
- lib/crewai-tools/tests/tools/test_oracle_vector_search_tool.py
- lib/crewai/tests/rag/embeddings/test_oracle_provider.py
- lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py
Adds Oracle integrations across CrewAI and crewai-tools.
This PR introduces an OracleVectorSearchTool for querying Oracle AI Vector Search tables from CrewAI tools. It supports Oracle-native vector distance search, JSON metadata filtering, score thresholds, configurable result limits, table creation, text insertion, HNSW/IVF vector index creation, custom embedding functions, OpenAI/Azure OpenAI embeddings, and caller-managed Oracle connections or connection pools.
It also adds Oracle as a CrewAI RAG embedding provider, backed by Oracle Database DBMS_VECTOR_CHAIN.UTL_TO_EMBEDDINGS, with support for either an existing Oracle connection or connection parameters and optional proxy configuration.
The integration is exported through the existing crewai-tools package APIs, adds an oracledb optional dependency extra, updates the lockfile, and includes README usage docs plus unit and integration tests for the vector search tool, metadata filtering, index creation, connection handling, and Oracle embedding provider behavior.
Summary by CodeRabbit
New Features
Dependencies
Documentation
Tests