Skip to content

Fix Desearch tools for desearch-py 1.1+ and pydantic v2 - #1

Merged
Chkhikvadze merged 1 commit into
mainfrom
cursor/fix-desearch-tools-0e31
Oct 1, 2026
Merged

Chkhikvadze merged 1 commit into
mainfrom
cursor/fix-desearch-tools-0e31

Conversation

@Chkhikvadze

Copy link
Copy Markdown
Contributor

Summary

langchain-desearch 1.0.6 fails on a fresh install because it is built against desearch-py 1.0.x and a pydantic v1-style validator. This release, 1.0.7, targets the current 1.x client (latest published release is 1.2.1) without renaming the public tools.

  • BasicWebSearchTool calls Desearch.web_search instead of the removed basic_web_search. num still limits how many hits are returned, and the existing 1-based start index is converted to the SDK's zero-based skip offset.
  • BasicTwitterSearchTool calls Desearch.x_search instead of the removed basic_twitter_search, and forwards the current X search filters (user, dates, language, verification, media, and engagement thresholds).
  • DesearchTool calls ai_search with the current parameters. model and streaming are still accepted so existing callers keep working; desearch-py 1.1+ does not send either of them (streaming is always false in the SDK).
  • The other X tools now call x_posts_by_urls, x_post_by_id, x_user_posts, x_user_replies, x_post_replies, and x_post_retweeters. Class names and tool names are unchanged. FetchRetweetsByPostTool follows the current retweeters endpoint (id plus optional cursor).
  • DesearchToolInput.check_tool_non_empty is a pydantic v2 mode="after" validator, so it reads self.tool on the model. The previous values.get("tool") raised AttributeError on every DesearchTool.invoke.

Dependency

desearch-py is now >=1.1.0,<2.0.0 in both pyproject.toml and setup.py. 1.1.0 is the first release with web_search / x_search; the upper bound keeps a future 2.0 from being installed automatically. Python requirement is >=3.9, matching desearch-py. Package version is 1.0.7. This change does not publish to PyPI and does not create a tag or GitHub release.

Tests

Mocked unit tests cover the validator, the method migration, pydantic model serialization, a missing API key, SDK errors, and sync calls made from inside a running event loop. .github/workflows/test.yml runs those tests on pull requests and on pushes to main.

A live smoke test was not run: DESEARCH_API_KEY is not set in this environment. Integration tests still skip unless that variable is present.

Open in Web Open in Cursor 

Fresh installs pulled desearch-py 1.2.1, which no longer provides
basic_web_search or basic_twitter_search. Call web_search, x_search, and
the current X endpoints, and require desearch-py>=1.1.0,<2.0.0.
The AI-search validator now reads the pydantic v2 model instead of calling
dict.get, which made every DesearchTool invoke fail.

Co-authored-by: Giga <cosmic@desearch.ai>
@Chkhikvadze
Chkhikvadze marked this pull request as ready for review October 1, 2026 19:36
@Chkhikvadze
Chkhikvadze merged commit 0009d4f into main Oct 1, 2026
2 checks passed
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