Skip to content

feat: add You.com API tools for search, content extraction, and research#5563

Open
EdwardIrby wants to merge 16 commits intocrewAIInc:mainfrom
youdotcom-oss:youdotcom-integration
Open

feat: add You.com API tools for search, content extraction, and research#5563
EdwardIrby wants to merge 16 commits intocrewAIInc:mainfrom
youdotcom-oss:youdotcom-integration

Conversation

@EdwardIrby
Copy link
Copy Markdown

Reopen of #4481 with upstream/main merged and review fixes applied.

Changes from original PR (#4481)

Bug Fixes (from code review)

  • [P1] Fix safesearch="off" silently dropped: Changed all parameter guards from truthy checks (if self.safesearch:) to explicit None checks (if self.safesearch is not None:). The old code would skip safesearch="off" since "off" is falsy.
  • [P1] Remove unreachable KeyError catch blocks: All three tools caught KeyError in _run() but no code path can produce one. The only dict access is os.environ["YOU_API_KEY"] which is validated in __init__.
  • [P2] Fix livecrawl_formats default: Changed from "markdown" to Nonelivecrawl_formats is only meaningful when livecrawl is set, so the default was misleading.

Free-Tier Search (breaking change)

  • Changed YouSearchTool endpoint from https://ydc-index.io/v1/search to https://api.you.com/v1/agents/search — this endpoint provides 100 free searches per day without an API key.
  • Made YOU_API_KEY optional for YouSearchTool: Removed the __init__ validation that required the key. The header is only sent when the key is present. Set YOU_API_KEY for higher rate limits.
  • Updated YouContentsTool URL from https://ydc-index.io/v1/contents to https://api.you.com/v1/contents.

Test Updates

  • Updated mock response shape from {"hits": [...]} to {"results": {"web": [...]}} matching the new endpoint response format
  • Added tests for free-tier usage (no API key)
  • Added tests for safesearch="off" and safesearch=None
  • Added test for livecrawl without livecrawl_formats
  • Fixed test_you_search_tool_missing_query to accept ValueError (raised by BaseTool validation)

Original Summary

This PR adds three new tools that integrate You.com's API:

  • YouSearchTool: Perform web searches with advanced operators, filters, pagination, and multilingual support (now free-tier!)
  • YouContentsTool: Extract content from URLs in markdown, HTML, or metadata formats
  • YouResearchTool: Multi-step research that runs multiple searches, reads sources, and synthesizes a thorough, well-cited answer

EdwardIrby and others added 16 commits February 13, 2026 14:02
  Add two new tools for the You.com API:

  - YouSearchTool: Web search with advanced operators, filters, and livecrawl
  support
  - YouContentsTool: Extract content from URLs in markdown, HTML, or metadata format

  Features:
  - Support for search operators (site:, filetype:, boolean logic)
  - Configurable parameters (count, country, freshness, safesearch)
  - Livecrawl options for full content extraction
  - Multiple output formats (markdown, html, metadata)
  - Comprehensive error handling and parameter validation
  - Full backwards compatibility with search_query parameter

  Implementation:
  - Follows crewAI tool patterns (BaseTool, EnvVar, Field)
  - Uses core requests dependency (no additional packages)
  - Includes README documentation with usage examples
  - API key available at https://you.com/platform/api-keys

  Testing:
  - 22 comprehensive tests covering initialization, functionality, and error
  handling
  - All tests use mocked API responses for reliability
  - Follows pytest patterns from existing tools
   Addresses Cursor Bugbot review feedback by removing runtime kwargs
   support from _run methods and using class properties exclusively.
   This matches the established crewAI tool pattern (TavilySearchTool,
   SerperDevTool) where:

   - Tool schema defines agent-callable parameters (query/urls)
   - Configuration options are class properties set during initialization
   - _run methods use class properties directly, not runtime kwargs

   Changes:
   - YouSearchTool._run: accepts only query parameter, uses class properties
   - YouContentsTool._run: accepts only urls parameter, uses class properties
   - Updated tests to set configuration via tool initialization
   - Removed backwards compatibility for search_query parameter

   This ensures agents can properly interact with the tools while
   maintaining flexibility through tool configuration at initialization.
   tools from root package

   Addresses Cursor Bugbot review #3799879658 by adding YouSearchTool and
   YouContentsTool to the root crewai_tools package exports.

   This enables the documented import path:
     from crewai_tools import YouSearchTool, YouContentsTool

   Previously the tools were only available via:
     from crewai_tools.tools import YouSearchTool, YouContentsTool

   Changes:
   - Add imports to crewai_tools/__init__.py
   - Add tools to __all__ list in alphabetical order
  Addresses Cursor Bugbot review #3799966503 by fixing two validation issues
  in YouSearchTool:

  1. Missing EN-US language code
     - README documented EN-US as supported language
     - Language Literal only included EN and EN-GB
     - Added EN-US to match documented behavior

  2. Unvalidated count parameter
     - API expects count in 1-100 range
     - No validation caused API errors with invalid values
     - Added clamping: max(1, min(self.count, 100))

  Changes:
  - Add EN-US to Language Literal type
  - Clamp count to valid range (1-100) before API request

  Test coverage: 25/25 tests passing
Addressed multiple issues identified in Cursor Bugbot reviews:

1. Added EN-US language code to YouSearchTool Language Literal
   - Language was documented in API but not available in enum
   - Enables proper BCP 47 language filtering

2. Added count parameter validation (1-100 range)
   - Prevents API errors from out-of-range values
   - Clamps count to valid range before API request

3. Fixed API endpoint URLs
   - Search: api.ydc-index.io/search → ydc-index.io/v1/search
   - Contents: api.ydc-index.io/contents → ydc-index.io/v1/contents
   - Verified against canonical source (api.constants.ts)

4. Fixed livecrawl_formats conditional logic
   - Now only sends livecrawl_formats when livecrawl is set
   - Prevents unnecessary parameter in API requests

5. Updated test assertions to match new endpoint URLs

All tests passing (25/25), linting and formatting checks clean.

Resolves: crewAIInc#4481 (reviews #3799966503, #3800020934)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PT-BR is a locale/language code, not an ISO 3166-1 alpha-2 country code.
It is absent from the You.com API spec's country enum and Brazil is already
represented by BR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EN-US is not present in the You.com Search API OpenAPI spec Language enum.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements YouResearchTool wrapping the POST /v1/research endpoint,
supporting configurable research_effort levels (lite/standard/deep/exhaustive)
with full test coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_run now falls back to self.research_effort when no per-call value
is provided, consistent with YouSearchTool/YouContentsTool patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gs across all You.com tools

- Change YouSearchTool URL from ydc-index.io/v1/search to api.you.com/v1/agents/search (100 free searches/day without API key)
- Make YOU_API_KEY optional for YouSearchTool (required=False, no __init__ validation)
- Fix safesearch='off' being silently dropped due to truthy check; use  checks throughout
- Fix livecrawl_formats default from 'markdown' to None (only sent when livecrawl is active)
- Remove unreachable KeyError catch blocks from all three tools
- Update YouContentsTool URL from ydc-index.io/v1/contents to api.you.com/v1/contents
- Update tests to match new URL, response shape, and add coverage for free-tier and safesearch=None

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.

2 participants