Skip to content

feat(tools): add WikipediaSearchTool#5835

Open
raghav-404 wants to merge 2 commits into
crewAIInc:mainfrom
raghav-404:feat/wikipedia-search-tool
Open

feat(tools): add WikipediaSearchTool#5835
raghav-404 wants to merge 2 commits into
crewAIInc:mainfrom
raghav-404:feat/wikipedia-search-tool

Conversation

@raghav-404
Copy link
Copy Markdown

@raghav-404 raghav-404 commented May 16, 2026

Closes #5823

Summary

Adds a new WikipediaSearchTool to crewai-tools for topic-based Wikipedia lookup with concise summaries.

What Changed

  • Added WikipediaSearchTool
  • Added support for concise Wikipedia summaries
  • Added handling for:
    • disambiguation errors
    • missing pages
    • missing optional dependency
  • Added tests for success and failure cases
  • Exported the tool from package entrypoints
  • Added the wikipedia dependency and updated lockfile

Testing

Ran:

  • uv run pytest lib/crewai-tools/tests/tools/test_wikipedia_search_tool.py
  • uv run ruff check lib/crewai-tools/src/crewai_tools/tools/wikipedia_search_tool lib/crewai-tools/tests/tools/test_wikipedia_search_tool.py lib/crewai-tools/src/crewai_tools/__init__.py lib/crewai-tools/src/crewai_tools/tools/__init__.py

Notes

The tool uses the wikipedia Python package and handles it as an optional dependency.

Summary by CodeRabbit

  • New Features
    • Introduced a Wikipedia search tool: query Wikipedia, control summary length, get suggestion lists for ambiguous terms, clear messages for missing pages, and readable error responses.
  • Chores
    • Added an optional wikipedia dependency to enable the feature.
  • Tests
    • Added tests covering success, disambiguation, page-not-found, unexpected errors, and missing-dependency behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

Adds a new WikipediaSearchTool that wraps the optional wikipedia package, provides a Pydantic input schema, handles disambiguation/page-not-found/generic errors, declares wikipedia as an optional dependency, wires exports through package init files, and adds tests for all scenarios.

Changes

WikipediaSearchTool Implementation

Layer / File(s) Summary
Tool implementation with schema and error handling
lib/crewai-tools/src/crewai_tools/tools/wikipedia_search_tool/wikipedia_search_tool.py
WikipediaSearchTool extends BaseTool with a Pydantic WikipediaSearchToolSchema input model (query, sentences). _run conditionally requires wikipedia, returns wikipedia.summary, maps DisambiguationError to ambiguity messages with up to 5 options, PageError to "no page found", other exceptions to generic error text, and raises ImportError with install instructions when wikipedia is unavailable.
Optional dependency declaration
lib/crewai-tools/pyproject.toml
Added wikipedia>=1.4.0 under [project.optional-dependencies] as the wikipedia group.
Package structure and multi-level exports
lib/crewai-tools/src/crewai_tools/tools/wikipedia_search_tool/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/__init__.py
Added re-exports so WikipediaSearchTool is available from the tool package and top-level crewai_tools package.
Comprehensive test coverage
lib/crewai-tools/tests/tools/test_wikipedia_search_tool.py
Added tests and fake exception types covering success, disambiguation, page-not-found, unexpected error, and missing-dependency behaviors. Tests patch WIKIPEDIA_AVAILABLE and the wikipedia module to simulate scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I hop through pages, line by line,
Summoning summaries, crisp and fine,
If pages split or nothing's found,
I gently say what I've found around,
Install me optional, and I'll fetch the sign.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed The title 'feat(tools): add WikipediaSearchTool' directly and accurately describes the main change—introducing a new tool called WikipediaSearchTool to the tools package.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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: 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/wikipedia_search_tool/wikipedia_search_tool.py`:
- Around line 20-22: The Field for "sentences" currently allows zero or negative
values; update the schema on the model that defines sentences (the sentences:
int = Field(...)) to enforce a lower bound (e.g., set ge=1 or add a Pydantic
validator on the same model/class) so inputs <1 are rejected at validation time;
locate the sentences Field in the wikipedia_search_tool model and add the
appropriate constraint (ge=1) or a validator to raise a ValidationError for
values <1.
🪄 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: fabdd6d5-0006-4376-b93c-7a33616bdf94

📥 Commits

Reviewing files that changed from the base of the PR and between a95d267 and 4db90e5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • 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/wikipedia_search_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/wikipedia_search_tool/wikipedia_search_tool.py
  • lib/crewai-tools/tests/tools/test_wikipedia_search_tool.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.

[FEATURE] Add native WikipediaSearchTool for free research

1 participant