Skip to content

Add Oracle Integrations#6026

Open
fileames wants to merge 4 commits into
crewAIInc:mainfrom
fileames:oracle_integration
Open

Add Oracle Integrations#6026
fileames wants to merge 4 commits into
crewAIInc:mainfrom
fileames:oracle_integration

Conversation

@fileames
Copy link
Copy Markdown

@fileames fileames commented Jun 3, 2026

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

    • Oracle vector search tool for similarity search with metadata filtering, indexing, ingestion, and embedding support.
    • Oracle added as an embedding provider for RAG and memory workflows.
  • Dependencies

    • Optional oracledb dependency group added to enable Oracle-related features.
  • Documentation

    • Comprehensive guide and examples for Oracle vector search usage and configuration.
  • Tests

    • New unit and integration tests covering Oracle tool and embedding provider.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9bb449c-e3bc-4fc5-bb7f-da3cdfabacd4

📥 Commits

Reviewing files that changed from the base of the PR and between d5ff3d4 and e76f820.

📒 Files selected for processing (1)
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py

📝 Walkthrough

Walkthrough

This 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.

Changes

Oracle Vector Search Tool

Layer / File(s) Summary
Tool dependencies and module exports
lib/crewai-tools/pyproject.toml, lib/crewai-tools/src/crewai_tools/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/__init__.py
Adds oracledb optional dependency and exposes Oracle vector-search types through package initializers.
Tool documentation
lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.md
Documentation covering installation, examples, index creation (HNSW/IVF), config options, usage patterns, and result payload fields.
Schemas and SQL/filter helpers
lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py
Pydantic schemas and utilities for LOB/Decimal normalization, identifier validation, and translating JSON-style filters into Oracle SQL with bind params.
Core tool implementation
lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py
OracleVectorSearchTool lifecycle: dependency checks, connection/OpenAI init, embedding helpers, table/index existence and creation, add_texts ingestion, _run() similarity search with merged filters and Python-side thresholding, and teardown.
Unit tests for vector search tool
lib/crewai-tools/tests/tools/test_oracle_vector_search_tool.py
Extensive unit tests using fakes/mocks for Oracle/OpenAI covering search, filtering semantics, index DDL, ingestion, SQL generation, and error branches.
Integration tests with real Oracle database
lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py
Integration tests (credential-gated) validating end-to-end table creation, insertion, unfiltered/filtered searches, and vector index creation/verification.

Oracle Embedding Provider for RAG

Layer / File(s) Summary
Embedding provider types and factory entries
lib/crewai/src/crewai/rag/embeddings/providers/oracle/types.py, lib/crewai/src/crewai/rag/embeddings/factory.py, lib/crewai/src/crewai/rag/embeddings/types.py, lib/crewai/src/crewai/rag/embeddings/providers/oracle/__init__.py
Adds TypedDicts for Oracle provider config/spec, registers provider path in PROVIDER_PATHS, adds overloads for build_embedder/build_embedder_from_dict, and re-exports Oracle provider types.
OracleEmbeddingFunction implementation
lib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.py
Embedding callable that posts JSON payloads to dbms_vector_chain.utl_to_embeddings via SYS.VECTOR_ARRAY_T, manages connection ownership, proxy setup, LOB fetching defaults, and returns float vectors.
OracleProvider model
lib/crewai/src/crewai/rag/embeddings/providers/oracle/oracle_provider.py
Pydantic provider exposing embedding_callable, conn/connection_params, required embedding_params, optional proxy, and validator enforcing exactly one connection source.
Unit tests for Oracle embedding provider
lib/crewai/tests/rag/embeddings/test_oracle_provider.py
Tests with fakes validating provider routing, connection reuse/creation, embedding execution and error cases, and cleanup behavior.
Integration tests with Memory and real Oracle
lib/crewai/tests/rag/embeddings/test_oracle_memory_integration.py
Credential-gated integration test building an Oracle embedder, validating embeddings, and exercising Memory remember/recall behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🐰 A rabbit hops through Oracle's halls,
With vectors dancing, search enthralls,
From embeddings bright to tables new,
We've woven databases through and through! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.89% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Oracle Integrations' clearly and concisely summarizes the main change in the changeset.
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

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee70702 and 40c9592.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • lib/crewai-tools/pyproject.toml
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool.py
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py
  • lib/crewai/src/crewai/rag/embeddings/factory.py
  • lib/crewai/src/crewai/rag/embeddings/providers/oracle/__init__.py
  • lib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.py
  • lib/crewai/src/crewai/rag/embeddings/providers/oracle/oracle_provider.py
  • lib/crewai/src/crewai/rag/embeddings/providers/oracle/types.py
  • lib/crewai/src/crewai/rag/embeddings/types.py
  • lib/crewai/tests/rag/embeddings/test_oracle_memory_integration.py
  • lib/crewai/tests/rag/embeddings/test_oracle_provider.py

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 40c9592 and d5ff3d4.

📒 Files selected for processing (6)
  • lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/oracle_vector_search_tool/vector_search.py
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool.py
  • lib/crewai-tools/tests/tools/test_oracle_vector_search_tool_integration.py
  • lib/crewai/src/crewai/rag/embeddings/providers/oracle/embedding_callable.py
  • lib/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

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.

1 participant