Skip to content

feat(crewai-tools): add IBM Db2 search tool#5885

Open
PawanThakurIBM wants to merge 42 commits into
crewAIInc:mainfrom
PawanThakurIBM:feat/db2-search-tool
Open

feat(crewai-tools): add IBM Db2 search tool#5885
PawanThakurIBM wants to merge 42 commits into
crewAIInc:mainfrom
PawanThakurIBM:feat/db2-search-tool

Conversation

@PawanThakurIBM

@PawanThakurIBM PawanThakurIBM commented May 21, 2026

Copy link
Copy Markdown

Closes #5925

Overview

This PR introduces a Db2 Vector Search Tool for CrewAI tools, enabling semantic/vector similarity search using Db2 native vector capabilities.

The implementation follows existing CrewAI tools architecture patterns to maintain consistency, extensibility, and maintainability across vector search integrations.


Components Added

DB2VectorSearchTool

Main CrewAI tool implementation providing:

  • vector similarity search
  • configurable distance metrics
  • configurable embedding model support
  • standardized JSON response formatting
  • runtime dependency loading

DB2Config

Configuration model for:

  • Db2 connection handling
  • retrieval configuration
  • embedding configuration
  • distance metric configuration

DB2ToolSchema

Pydantic-based input schema for:

  • query validation
  • metadata filtering parameters
  • runtime input validation

Features

Vector Search Support

Provides semantic/vector similarity retrieval using Db2 native vector functionality with:

  • configurable distance metrics
  • top-k retrieval support

Flexible Embedding Support

Supports:

  • OpenAI embedding generation
  • configurable embedding models
  • optional custom embedding functions

Validation & Security

Added validation and sanitization support for:

  • Db2 identifiers
  • distance metrics
  • retrieval configuration
  • input validation
  • safer query construction

Connection Lifecycle Management

Added support for:

  • Db2 connection setup
  • cursor initialization
  • safe cleanup/disconnection
  • runtime connection handling

Serialization Handling

Implemented standardized JSON serialization support for Db2-specific response types including:

  • Decimal
  • datetime
  • binary payloads

Current Scope

This implementation currently focuses on:

  • semantic retrieval
  • vector similarity search
  • Db2 integration

The following are currently out of scope:

  • ingestion pipelines
  • document chunking workflows
  • hybrid retrieval
  • async support

Testing

Completed end-to-end local testing for:

  • Db2 connection flow
  • embedding generation
  • vector similarity search execution
  • retrieval response handling

Documentation

Added documentation covering:

  • installation and setup
  • configuration options
  • semantic retrieval workflows
  • custom embedding support
  • filtering support
  • usage examples

Summary by CodeRabbit

  • New Features

    • DB2 Vector Search Tool: semantic vector search against DB2 with OpenAI or custom embeddings, selectable distance metrics, result shaping, result limits, and optional metadata filtering.
  • Breaking Changes

    • DirectoryReadTool is no longer publicly exported from the tools package.
  • Documentation

    • New user docs and README covering installation, configuration, examples, environment variables, security notes, and a full semantic search workflow.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a DB2-native vector search tool: Pydantic schemas and JSON encoder, DB2VectorSearchTool with dynamic driver loading, OpenAI/custom embeddings, parameterized VECTOR_DISTANCE queries (optional metadata filtering), package export updates, README, and MDX user documentation.

Changes

DB2 Vector Search Tool for CrewAI

Layer / File(s) Summary
Data contracts and configuration schemas
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py
Imports, DB2JSONEncoder for serializing Decimal/date/bytes types, DB2ToolSchema input contract with query and optional filter_by/filter_value, and DB2Config for DB2 connection and vector-search options (table/column, embedding model, distance metric, limit, max_distance).
DB2VectorSearchTool class and query execution
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py
DB2VectorSearchTool implements dynamic DB2 driver imports, connection/cursor lifecycle, SQL identifier validation, _generate_embedding() (OpenAI or custom), _run() performing embedding generation, parameterized VECTOR_DISTANCE SQL execution with optional metadata WHERE clause, client-side max_distance filtering, result normalization to JSON, structured error payloads, and __del__() cleanup.
Package exports and module integration
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py
DB2 package __init__.py re-exports DB2Config, DB2ToolSchema, DB2VectorSearchTool; main tools __init__ import/export for DirectoryReadTool commented out (no longer re-exported).
User-facing documentation and README
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md, docs/en/tools/database-data/db2searchtool.mdx
README documents installation, env vars, usage examples (basic and metadata-filtered), and architecture; MDX guide includes full semantic search workflow, DB2Config fields, supported distance metrics, embedding options (OpenAI default and custom examples), error/validation notes, and JSON result shape.

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant DB2VectorSearchTool
  participant DB2
  participant OpenAIEmbeddings
  Agent->>DB2VectorSearchTool: call _run(query, filter_by?, filter_value?)
  DB2VectorSearchTool->>OpenAIEmbeddings: request embedding (if no custom fn)
  OpenAIEmbeddings-->>DB2VectorSearchTool: embedding vector
  DB2VectorSearchTool->>DB2: execute PARAMETERIZED VECTOR_DISTANCE query
  DB2-->>DB2VectorSearchTool: rows with distances
  DB2VectorSearchTool-->>Agent: JSON results (distance + data)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

"A rabbit peeks at code and hops with glee,
New DB2 paths for vectors set free.
Embeddings fetched, results returned in kind,
Search and filter, tidy JSON aligned.
🐇✨"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes include intentional removal of DirectoryReadTool export and a new DB2 tool implementation, but the PR commentary indicates this is part of unresolved work requiring file export updates to properly expose DB2 components and manage other tool exports. Complete the pending fixes identified in PR comments: restore DirectoryReadTool export in tools init.py, add DB2 exports to tools init.py, and ensure all public exports are properly declared in all lists.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding an IBM Db2 search tool to the crewai-tools package.
Linked Issues check ✅ Passed The PR implements all core objectives from issue #5925: vector similarity search, configurable distance metrics, metadata filtering, embedding model support, custom embedding functions, and standardized JSON responses following CrewAI tools architecture.

✏️ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 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/__init__.py`:
- Around line 56-58: Restore the central exports by importing and re-exporting
the missing tool symbols in crewi_tools.tools.__init__: re-enable the
DirectoryReadTool import from
crewi_tools.tools.directory_read_tool.directory_read_tool and add imports for
the DB2 tool classes (e.g., the DB2 tool module(s) under
crewi_tools.tools.db2_*) and include those symbol names in the module's __all__
so consumers can import them from crewi_tools.tools; ensure you import the exact
class/function names from their modules and add them to the exported list (also
apply the same changes to the other affected export block referenced in the
comment).

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`:
- Around line 252-255: The except block handling failures from _connect() should
clean up any partially opened resources: if self.connection was created but
cursor setup failed, close the connection (or call the existing cleanup method,
e.g., self._close()) before returning the error JSON; update the try/except to
check for self.connection (and any partially created cursor) and close them on
exception or move cleanup into a finally block so no DB2 connection is leaked
when _connect() raises.
- Around line 37-51: The schema allows one-sided filter inputs; add a Pydantic
validator that enforces filter_by and filter_value are provided together (both
non-None) or both None. Locate the model containing the Field definitions for
filter_by and filter_value and implement either a `@root_validator`(pre=False) or
paired `@validator` methods to raise a ValueError when one is set and the other is
not (referencing the filter_by and filter_value symbols), ensuring the runtime
check aligns with the existing filtering logic that only applies when both are
present.
- Around line 110-115: The package list in the DB2VectorSearchTool model is
missing the DBI package so dependency automation won't install the module
imported in _setup_db2; update the package_dependencies Field (in the
DB2VectorSearchTool declaration) to include "ibm_db_dbi" alongside "ibm_db" and
"openai" so the default db2_dbi_package used in _setup_db2 is available at
runtime. Ensure the string matches the default db2_dbi_package value
("ibm_db_dbi") to avoid mismatches.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md`:
- Around line 40-57: Update the README examples to use the public module path
and public API: change the import to crewai_tools.tools.db2_search_tool and
instantiate DB2Config and DB2VectorSearchTool as shown, then call the public
method run(...) instead of the private _run(...); also update any
metadata-filtering example that currently calls _run to call run and pass the
same parameters so examples reference DB2Config, DB2VectorSearchTool, run, and
no longer use _run.
🪄 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: 8ba82584-3681-434d-b317-d49455cf3284

📥 Commits

Reviewing files that changed from the base of the PR and between 867df0f and 61d668b.

📒 Files selected for processing (5)
  • docs/en/tools/database-data/db2searchtool.mdx
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

Comment thread lib/crewai-tools/src/crewai_tools/tools/__init__.py Outdated
Comment thread lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py Outdated
Comment on lines +40 to +57
from db2_search_tool import (
DB2Config,
DB2VectorSearchTool,
)

config = DB2Config(
database="TESTDB",
hostname="localhost",
table_name="documents",
)

tool = DB2VectorSearchTool(
db2_config=config
)

result = tool._run(
query="What is machine learning?",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "from db2_search_tool|\\._run\\(" lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md docs/en/tools/database-data/db2searchtool.mdx

Repository: crewAIInc/crewAI

Length of output: 337


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate tool implementation
rg -n "class DB2VectorSearchTool" -S lib/crewai-tools/src/crewai_tools/tools/db2_search_tool || true
rg -n "def (run|_run)\b" -S lib/crewai-tools/src/crewai_tools/tools/db2_search_tool || true

# Find how the module is exported (public import path)
rg -n "DB2Config|DB2VectorSearchTool" -S lib/crewai-tools/src/crewai_tools/tools/db2_search_tool || true
fd -t f "__init__.py" lib/crewai-tools/src/crewai_tools/tools/db2_search_tool -a | head -n 50

Repository: crewAIInc/crewAI

Length of output: 1657


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check any top-level exports that might make `from db2_search_tool import ...` valid
rg -n "from (db2_search_tool|crewai_tools\.tools\.db2_search_tool)" -S lib/crewai-tools/src/crewai_tools || true
rg -n "db2_search_tool" -S lib/crewai-tools/src/crewai_tools | head -n 200

Repository: crewAIInc/crewAI

Length of output: 359


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the README around the flagged lines
nl -ba lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md | sed -n '30,90p'

Repository: crewAIInc/crewAI

Length of output: 103


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect similar tool READMEs for doc conventions (import path + run vs _run)
fd -t f "README.md" lib/crewai-tools/src/crewai_tools/tools -a | head -n 200
# Pick a couple likely vector-search tools and grep their examples
for f in $(fd -t f "README.md" lib/crewai-tools/src/crewai_tools/tools -a | rg -i "vector|search|database" | head -n 10); do
  echo "---- $f ----"
  rg -n "from .*db|_run|\.run\(" "$f" || true
done

Repository: crewAIInc/crewAI

Length of output: 7748


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Read the DB2 README with line numbers (cat -n is available)
echo "=== db2_search_tool README (1-120) ==="
cat -n lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md | sed -n '1,120p'

# 2) Inspect DB2 tool implementation around _run
echo
echo "=== db2_search_tool.py (80-320) ==="
sed -n '1,220p' lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py | head -n 220
echo
sed -n '220,340p' lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py | head -n 140

# 3) Find BaseTool definition and run/_run behavior
echo
echo "=== Locate BaseTool ==="
rg -n "class BaseTool" lib/crewai-tools/src -S || true
rg -n "def run\\(" lib/crewai-tools/src -S || true
rg -n "def _run\\(" lib/crewai-tools/src -S | head -n 50 || true

# 4) Inspect BaseTool.run if found
base_tool_file="$(rg -n "class BaseTool" lib/crewai-tools/src -S --files-with-matches | head -n 1 || true)"
echo
echo "=== BaseTool file: ${base_tool_file:-<none>} ==="
if [[ -n "${base_tool_file:-}" ]]; then
  sed -n '1,220p' "$base_tool_file" | head -n 220
  rg -n "def run\\(" "$base_tool_file" -n -S || true
  # print around run if exists
  if rg -n "def run\\(" "$base_tool_file" -S >/dev/null; then
    line="$(rg -n "def run\\(" "$base_tool_file" -n -S | head -n 1 | cut -d: -f1)"
    start=$((line-40))
    end=$((line+80))
    sed -n "${start},${end}p" "$base_tool_file" | head -n 200
  fi
fi

# 5) Compare README conventions with a couple similar tools
echo
echo "=== Check other tool READMEs for import style + _run usage ==="
for f in \
  lib/crewai-tools/src/crewai_tools/tools/firecrawl_search_tool/README.md \
  lib/crewai-tools/src/crewai_tools/tools/qdrant_vector_search_tool/README.md \
  lib/crewai-tools/src/crewai_tools/tools/weaviate_tool/README.md \
  lib/crewai-tools/src/crewai_tools/tools/mongodb_vector_search_tool/README.md \
  lib/crewai-tools/src/crewai_tools/tools/rag/README.md \
; do
  echo "--- $f (import + run/_run lines) ---"
  rg -n "^from .* import \\(" "$f" || true
  rg -n "_run\\(" "$f" || true
  rg -n "\\.run\\(" "$f" || true
done

Repository: crewAIInc/crewAI

Length of output: 19605


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find BaseTool implementation in the whole repo
rg -n "class BaseTool" . -S --hidden --no-ignore || true
base_tool_file="$(rg -n "class BaseTool" . -S --hidden --no-ignore --files-with-matches | head -n 1 || true)"
echo "BaseTool file: ${base_tool_file:-<none>}"

# 2) If found, inspect around run/_run
if [[ -n "${base_tool_file:-}" ]]; then
  sed -n '1,260p' "$base_tool_file" | head -n 260
  rg -n "def run\\(" "$base_tool_file" -n -S || true
  rg -n "def _run\\(" "$base_tool_file" -n -S || true
  # print around def run if present
  if rg -n "def run\\(" "$base_tool_file" -n -S >/dev/null; then
    line="$(rg -n "def run\\(" "$base_tool_file" -n -S | head -n 1 | cut -d: -f1)"
    start=$((line-60)); end=$((line+120))
    sed -n "${start},${end}p" "$base_tool_file" | head -n 220
  fi
fi

# 3) Inspect db2_search_tool package __init__.py (for export path clues)
echo
echo "=== db2_search_tool __init__.py ==="
cat lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/__init__.py

# 4) Check if there is any top-level module/package named db2_search_tool
echo
echo "=== any top-level db2_search_tool occurrences ==="
fd -t d "db2_search_tool" . --hidden --no-ignore || true
fd -t f "db2_search_tool.py" . --hidden --no-ignore || true
rg -n "from db2_search_tool import" . -S --hidden --no-ignore || true

# 5) Inspect one other README that uses `run()` to see import conventions
echo
echo "=== firecrawl_search_tool README (relevant section) ==="
sed -n '1,120p' lib/crewai-tools/src/crewai_tools/tools/firecrawl_search_tool/README.md

echo
echo "=== qdrant_vector_search_tool README (relevant section) ==="
sed -n '1,120p' lib/crewai-tools/src/crewai_tools/tools/qdrant_vector_search_tool/README.md

Repository: crewAIInc/crewAI

Length of output: 18542


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find where DB2VectorSearchTool is exported publicly
rg -n "DB2VectorSearchTool" lib/crewai-tools/src/crewai_tools -S

# Inspect crewai_tools root __init__ to see public exports
ls -la lib/crewai-tools/src/crewai_tools | head
cat lib/crewai-tools/src/crewai_tools/__init__.py | sed -n '1,220p'

# Also inspect crewai_tools/tools/__init__.py if present
if [[ -f lib/crewai-tools/src/crewai_tools/tools/__init__.py ]]; then
  echo "=== crewai_tools/tools/__init__.py ==="
  cat lib/crewai-tools/src/crewai_tools/tools/__init__.py | sed -n '1,260p'
fi

# Confirm any documented import paths elsewhere
rg -n "from crewai_tools import .*DB2" -S lib/crewai-tools/src docs || true
rg -n "DB2VectorSearchTool" -S docs lib/crewai-tools/src | head -n 50

Repository: crewAIInc/crewAI

Length of output: 23011


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect DB2 docs usage of run/_run and import path
echo "=== db2searchtool.mdx (imports + example blocks) ==="
rg -n "from crewai_tools import DB2VectorSearchTool, DB2Config|tool\\.(run|_run)\\(" docs/en/tools/database-data/db2searchtool.mdx
echo
# Show surrounding lines around each tool.run/_run call
rg -n "tool\\.(run|_run)\\(" docs/en/tools/database-data/db2searchtool.mdx -n --with-filename | cut -d: -f1-3 >/dev/null || true
# Use sed range around the first few matches
line_nums=$(rg -n "tool\\.(run|_run)\\(" docs/en/tools/database-data/db2searchtool.mdx | head -n 10 | cut -d: -f1)
for ln in $line_nums; do
  start=$((ln-15)); end=$((ln+15));
  echo "---- around line $ln ----"
  sed -n "${start},${end}p" docs/en/tools/database-data/db2searchtool.mdx | nl -ba | head -n 80
done

# Inspect crewai_tools top-level exports for DB2VectorSearchTool
echo
echo "=== crewai_tools/__init__.py DB2 exports ==="
rg -n "DB2VectorSearchTool|DB2Config" lib/crewai-tools/src/crewai_tools/__init__.py -n || true

Repository: crewAIInc/crewAI

Length of output: 407


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== crewai_tools/__init__.py (DB2-related lines) ==="
rg -n "DB2VectorSearchTool|DB2Config" lib/crewai-tools/src/crewai_tools/__init__.py -n || true
echo
echo "=== db2searchtool.mdx (around run usage) ==="
sed -n '140,210p' docs/en/tools/database-data/db2searchtool.mdx
echo
echo "=== db2searchtool.mdx (around later example usage) ==="
sed -n '210,270p' docs/en/tools/database-data/db2searchtool.mdx

Repository: crewAIInc/crewAI

Length of output: 4265


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "DB2VectorSearchTool" lib/crewai-tools/src/crewai_tools/__init__.py lib/crewai-tools/src/crewai_tools/tools/__init__.py
rg -n "DB2Config" lib/crewai-tools/src/crewai_tools/__init__.py lib/crewai-tools/src/crewai_tools/tools/__init__.py

Repository: crewAIInc/crewAI

Length of output: 42


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for DB2 export occurrences anywhere under crewai_tools
rg -n "DB2VectorSearchTool" lib/crewai-tools/src/crewai_tools -S || true
echo "----"
rg -n "db2_search_tool" lib/crewai-tools/src/crewai_tools -S || true
echo "----"

# Inspect root __init__.py export mechanism (look for star imports / __all__)
cat lib/crewai-tools/src/crewai_tools/__init__.py | sed -n '1,260p'
echo "---- (tail) ----"
tail -n 120 lib/crewai-tools/src/crewai_tools/__init__.py

Repository: crewAIInc/crewAI

Length of output: 14900


🏁 Script executed:

rg -n "DB2VectorSearchTool|DB2Config" lib/crewai-tools/src/crewai_tools/__init__.py -S || true

Repository: crewAIInc/crewAI

Length of output: 42


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "DB2VectorSearchTool|DB2Config" lib/crewai-tools/src/crewai_tools/tools/__init__.py -S || true
rg -n "db2_search_tool" lib/crewai-tools/src/crewai_tools/tools/__init__.py -S || true

Repository: crewAIInc/crewAI

Length of output: 42


Fix DB2 README example to use public import path and run()

README uses from db2_search_tool import ... and calls the private tool._run(...). Update the example to import from crewai_tools.tools.db2_search_tool and call tool.run(...) (also update the metadata-filtering snippet that uses _run()).

Suggested fix
-from db2_search_tool import (
+from crewai_tools.tools.db2_search_tool import (
     DB2Config,
     DB2VectorSearchTool,
 )
@@
-result = tool._run(
+result = tool.run(
     query="What is machine learning?",
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from db2_search_tool import (
DB2Config,
DB2VectorSearchTool,
)
config = DB2Config(
database="TESTDB",
hostname="localhost",
table_name="documents",
)
tool = DB2VectorSearchTool(
db2_config=config
)
result = tool._run(
query="What is machine learning?",
)
from crewai_tools.tools.db2_search_tool import (
DB2Config,
DB2VectorSearchTool,
)
config = DB2Config(
database="TESTDB",
hostname="localhost",
table_name="documents",
)
tool = DB2VectorSearchTool(
db2_config=config
)
result = tool.run(
query="What is machine learning?",
)
🤖 Prompt for 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.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md` around
lines 40 - 57, Update the README examples to use the public module path and
public API: change the import to crewai_tools.tools.db2_search_tool and
instantiate DB2Config and DB2VectorSearchTool as shown, then call the public
method run(...) instead of the private _run(...); also update any
metadata-filtering example that currently calls _run to call run and pass the
same parameters so examples reference DB2Config, DB2VectorSearchTool, run, and
no longer use _run.

@PawanThakurIBM PawanThakurIBM changed the title feat(crewai-tools): add db2 search tool feat(crewai-tools): add IBM Db2 search tool May 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`:
- Around line 53-57: The _validate_filter_pair model validator in DB2ToolSchema
only checks None pairing and allows empty or whitespace-only filter_by which
later gets ignored; update _validate_filter_pair to also reject blank/whitespace
filter_by when filter_value is provided (and vice versa), by treating filter_by
as required to be a non-empty truthy string (e.g., strip() check) whenever
filter_value is not None, and raise ValueError("filter_by and filter_value must
be provided together.") for invalid pairs so the later filtering logic that
checks truthiness behaves correctly.
🪄 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: 66d237cf-253b-46e3-bc2a-e7b8f2935d73

📥 Commits

Reviewing files that changed from the base of the PR and between a53a27a and d14196e.

📒 Files selected for processing (1)
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py (1)

78-80: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Prevent empty return_columns to avoid invalid SQL syntax.

If return_columns is an empty list, line 290 produces column_query="", resulting in malformed SQL (SELECT , VECTOR_DISTANCE...). Add a minimum length constraint.

Suggested fix
     return_columns: list[str] = Field(
-        default_factory=lambda: ["content"]
+        default_factory=lambda: ["content"],
+        min_length=1,
+        description="Columns to return from the database. At least one required."
     )
🤖 Prompt for 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.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`
around lines 78 - 80, The return_columns Field is allowed to be an empty list
which leads to a malformed SQL fragment when building column_query (e.g., SELECT
, VECTOR_DISTANCE...), so add validation on the return_columns Field (or in the
class __post_init__/validate method) to ensure its length is >=1; if empty
either raise a clear ValueError describing the requirement or coerce it back to
the default ["content"]. Update code that builds column_query to assume
return_columns is non-empty (or defensively join with a fallback), referencing
the return_columns Field and the column_query construction to locate where to
add the check.
🤖 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.

Outside diff comments:
In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`:
- Around line 78-80: The return_columns Field is allowed to be an empty list
which leads to a malformed SQL fragment when building column_query (e.g., SELECT
, VECTOR_DISTANCE...), so add validation on the return_columns Field (or in the
class __post_init__/validate method) to ensure its length is >=1; if empty
either raise a clear ValueError describing the requirement or coerce it back to
the default ["content"]. Update code that builds column_query to assume
return_columns is non-empty (or defensively join with a fallback), referencing
the return_columns Field and the column_query construction to locate where to
add the check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9207b9b7-f5b3-419e-8cf8-a638eacb4a61

📥 Commits

Reviewing files that changed from the base of the PR and between d14196e and 0e1b992.

📒 Files selected for processing (1)
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

@priyanshu-krishnan1

Copy link
Copy Markdown

Fix all unresolved @CodeRabbit comments on this PR

@priyanshu-krishnan1

Copy link
Copy Markdown

@coderabbitai help

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@priyanshu-krishnan1

Copy link
Copy Markdown

@coderabbitai autofix

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch all review comments by coderabbitai on PR `#5885`
gh pr view 5885 --repo crewAIInc/crewAI --json reviews,comments

echo "=== Review thread comments ==="
gh api repos/crewAIInc/crewAI/pulls/5885/comments --paginate | jq '[.[] | select(.user.login == "coderabbitai") | {id, path, line, body, in_reply_to_id}]'

echo "=== Issue comments ==="
gh api repos/crewAIInc/crewAI/issues/5885/comments --paginate | jq '[.[] | select(.user.login == "coderabbitai") | {id, body}]'

echo "=== All review threads with resolution status ==="
gh api repos/crewAIInc/crewAI/pulls/5885/reviews --paginate | jq '[.[] | select(.user.login == "coderabbitai") | {id, state, body, submitted_at}]'

Length of output: 35016


🏁 Script executed:

#!/bin/bash
echo "=== __init__.py ==="
cat lib/crewai-tools/src/crewai_tools/tools/__init__.py

echo ""
echo "=== db2_search_tool.py ==="
cat lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

echo ""
echo "=== README.md ==="
cat lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md

echo ""
echo "=== db2_search_tool __init__.py ==="
cat lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/__init__.py

Length of output: 25056



I've analyzed the current code. Here's what's already fixed vs. still unresolved:

Already fixed ✅

  • _connect() exception cleanup (calls _disconnect() in except block)
  • filter_by/filter_value pair validation (including whitespace check)

Still unresolved ❌ — planning fixes now:

  • Fix lib/crewai-tools/src/crewai_tools/tools/__init__.py: restore DirectoryReadTool and add DB2 tool exports
  • Fix lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py: add ibm_db_dbi to package_dependencies and add min_length=1 to return_columns
  • Fix lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md: fix import path and replace _run() with run()

Failed to handle agent chat message. Please try again.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

❌ Failed to clone repository into sandbox. Please try again.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py (3)

335-349: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Return one top-level JSON shape on both success and failure.

Success currently returns a bare list, while failures return an object with success/error. That forces consumers to branch on JSON type instead of a stable contract for this public tool API. Wrap successful results in the same envelope, e.g. {"success": true, "results": [...]}.

🤖 Prompt for 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.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`
around lines 335 - 349, The success path currently returns a bare list
(normalized_results) while the exception path returns an envelope with
success/error fields; update the success return in the function that produces
normalized_results (referencing normalized_results, DB2JSONEncoder, and
self._disconnect) to return a top-level envelope like {"success": True,
"results": normalized_results} serialized with json.dumps using the same indent
and cls=DB2JSONEncoder so both success and failure share a stable JSON shape.

249-257: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Short-circuit blank queries before calling the embedder.

query="" or whitespace-only input reaches _generate_embedding(), so this can still spend an embedding request and a DB roundtrip on meaningless input. A fast guard here would keep the runtime behavior aligned with the tool's input-validation contract.

🤖 Prompt for 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.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`
around lines 249 - 257, Short-circuit blank or whitespace-only queries at the
start of _run to avoid calling _generate_embedding and making unnecessary
embedding/DB requests: add a guard that checks if query is None or query.strip()
== "" and return an early descriptive string/error (consistent with the tool's
input-validation contract) before any call to _generate_embedding or DB
operations in the _run method.

77-80: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reject empty return_columns.

DB2Config(return_columns=[]) is accepted here, but _run() later turns that into SELECT , VECTOR_DISTANCE(...), which is invalid SQL after you've already generated an embedding and opened a connection. Fail fast on an empty list in the config layer.

🤖 Prompt for 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.

In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`
around lines 77 - 80, DB2Config currently allows return_columns to be an empty
list which later causes invalid SQL in _run() (producing "SELECT ,
VECTOR_DISTANCE(...)"); validate return_columns in the DB2Config constructor or
model (the Field/default_factory for return_columns) to reject empty lists and
raise a clear ValueError, or add a pydantic validator on DB2Config that checks
return_columns is a non-empty list; ensure the error is raised early (before
embedding generation/connection) and reference the return_columns Field and
DB2Config/_run() in the message so callers understand the misconfiguration.
🤖 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.

Outside diff comments:
In `@lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py`:
- Around line 335-349: The success path currently returns a bare list
(normalized_results) while the exception path returns an envelope with
success/error fields; update the success return in the function that produces
normalized_results (referencing normalized_results, DB2JSONEncoder, and
self._disconnect) to return a top-level envelope like {"success": True,
"results": normalized_results} serialized with json.dumps using the same indent
and cls=DB2JSONEncoder so both success and failure share a stable JSON shape.
- Around line 249-257: Short-circuit blank or whitespace-only queries at the
start of _run to avoid calling _generate_embedding and making unnecessary
embedding/DB requests: add a guard that checks if query is None or query.strip()
== "" and return an early descriptive string/error (consistent with the tool's
input-validation contract) before any call to _generate_embedding or DB
operations in the _run method.
- Around line 77-80: DB2Config currently allows return_columns to be an empty
list which later causes invalid SQL in _run() (producing "SELECT ,
VECTOR_DISTANCE(...)"); validate return_columns in the DB2Config constructor or
model (the Field/default_factory for return_columns) to reject empty lists and
raise a clear ValueError, or add a pydantic validator on DB2Config that checks
return_columns is a non-empty list; ensure the error is raised early (before
embedding generation/connection) and reference the return_columns Field and
DB2Config/_run() in the message so callers understand the misconfiguration.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4242fd09-330d-47e7-a6f9-5845c35b648f

📥 Commits

Reviewing files that changed from the base of the PR and between 0e1b992 and 60f9dc1.

📒 Files selected for processing (1)
  • lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

@priyanshu-krishnan1

Copy link
Copy Markdown

Hi @greysonlalonde,
I noticed you’ve reviewed several CrewAI tools contributions recently.
I’d really appreciate your feedback on this IBM DB2 Vector Search Tool implementation whenever you have some time.
Thank you!

@PawanThakurIBM
PawanThakurIBM force-pushed the feat/db2-search-tool branch from 37e11be to 468149e Compare May 28, 2026 13:08
Comment thread lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py Outdated
@PawanThakurIBM
PawanThakurIBM force-pushed the feat/db2-search-tool branch from 9655947 to b22fe41 Compare July 7, 2026 11:15
priyanshu-krishnan1 and others added 6 commits July 13, 2026 11:17
…ibm-db2-review-fix

# Conflicts:
#	docs/v1.13.0/en/tools/database-data/db2searchtool.mdx
#	lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/README.md
#	lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/__init__.py
#	lib/crewai-tools/src/crewai_tools/tools/db2_search_tool/db2_search_tool.py

@lorenzejay lorenzejay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review findings from the current head. These should be addressed before merge; I left the PR approval state unchanged.

return self

db2_package: ImportString[Any] = Field(
default="ibm_db",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ImportString does not validate default values unless default validation is enabled, so the documented/default construction leaves db2_package and db2_dbi_package as plain strings. _connect() then fails on self.db2_package.connect(...). Please enable default validation, use factories that import the modules, or resolve them explicitly in _connect(), and add a test that does not inject these two fields.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Totally valid catch. We dropped ImportString from both fields and moved resolution into _connect() via _resolve_db2_packages(), which handles both None defaults and explicit string names like "ibm_db". Also added test_connect_resolves_packages_without_injection — constructs the tool without injecting either field and drives through _connect() to confirm the packages get resolved and the connection comes up.


```python
from crewai import Agent
from crewai_tools import DB2VectorSearchTool, DB2Config

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This documented public API does not exist: the PR does not export DB2VectorSearchTool from crewai_tools, and no DB2Config class is implemented or exported. As written, every example fails at import time. Please either implement/export the documented API or update all examples to the actual constructor and make that constructor publicly importable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed — DB2Config never existed and DB2VectorSearchTool wasn't exported, so all examples were broken at import. Both DB2VectorSearchTool and DB2ToolSchema are now exported from crewai_tools, and all examples have been updated to use the actual connection_string constructor.

_ALLOWED_METRICS: ClassVar[set[str]] = {
"COSINE",
"EUCLIDEAN",
"DOT_PRODUCT",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These metric names do not match Db2's VECTOR_DISTANCE API. Db2 supports COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, and MANHATTAN; DOT_PRODUCT and L2_DISTANCE will be accepted here but fail when the SQL executes. Please align the whitelist and documentation with the Db2 names: https://www.ibm.com/docs/en/db2/12.1.x?topic=functions-vector-distance

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — DOT_PRODUCT and L2_DISTANCE were incorrect and would have passed the whitelist check before failing silently at SQL execution. We've updated _ALLOWED_METRICS to exactly match the Db2 VECTOR_DISTANCE API: COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, and MANHATTAN. The docs have been updated to reflect the same six values with a link to the IBM reference.

DirectoryReadTool,
)
# from crewai_tools.tools.directory_read_tool.directory_read_tool import (
# DirectoryReadTool,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an unrelated public API regression: it breaks from crewai_tools.tools import DirectoryReadTool. Please restore both this import and the corresponding __all__ entry; adding the Db2 tool should not remove an existing tool export.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — DirectoryReadTool was accidentally commented out when the DB2 tool imports were added. We've restored both the import and the all entry, so from crewai_tools import DirectoryReadTool works correctly again.

@@ -0,0 +1,279 @@
---

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Repository policy treats docs/v*/ as frozen release snapshots managed by devtools. New documentation should be added under docs/edge/en/ and referenced from docs/docs.json when needed, rather than modifying a versioned snapshot.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The frozen snapshot has been cleaned up — docs/v1.13.0/en/tools/database-data/db2searchtool.mdx was deleted entirely, and the documentation now lives at docs/edge/en/tools/database-data/db2searchtool.mdx with a corresponding entry in docs/docs.json. No versioned snapshot directories were modified.

Dhruv Chaturvedi and others added 2 commits July 22, 2026 11:51
- Restore DirectoryReadTool export accidentally removed; add DB2VectorSearchTool
  and DB2ToolSchema to crewai_tools.tools __init__ and __all__
- Align _ALLOWED_METRICS whitelist with Db2 VECTOR_DISTANCE API:
  replace DOT_PRODUCT/L2_DISTANCE with EUCLIDEAN_SQUARED/DOT/HAMMING/MANHATTAN
- Replace ImportString fields for db2_package/db2_dbi_package with plain Any +
  lazy importlib.import_module in new _resolve_db2_packages() to avoid Pydantic
  default-validation gap where strings were never resolved at construction time
- Move docs from frozen docs/v1.13.0/ snapshot to docs/edge/en/tools/database-data/
  and register in docs/docs.json; update examples to match actual API
  (connection_string constructor, not DB2Config), correct return format, and
  align documented distance metrics with the whitelist
…-fixes

fix(db2-search-tool): address PR review comments

@lorenzejay lorenzejay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two remaining issues:


```python
from crewai import Agent
from crewai_tools import DB2VectorSearchTool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This import still fails: DB2VectorSearchTool was added to crewai_tools.tools, but not the package-level crewai_tools/__init__.py. Please export it there and add a public-import test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Missed this one — DB2VectorSearchTool was only exported from crewai_tools.tools, not from the top-level crewai_tools package, so from crewai_tools import DB2VectorSearchTool would fail at import. Both DB2VectorSearchTool and DB2ToolSchema are now in crewai_tools/init.py and all. Added test_public_import_from_crewai_tools to cover the package-level import explicitly. All 70 tests passing.

# Installation

```bash
pip install ibm_db ibm_db_dbi openai

@lorenzejay lorenzejay Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ibm_db_dbi is bundled with ibm_db, not a separate PyPI package. Please use uv add ibm_db openai.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ibm_db_dbi is bundled with ibm_db so it doesn't need to be listed separately — removed it. Also switched pip install to uv add to match the repo convention, and updated the example import to use the public from crewai_tools import DB2VectorSearchTool path now that it's properly exported at the package level.

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.

Add IBM Db2 Vector Search Tool for semantic retrieval workflows

4 participants