Skip to content

Duckduckgo Runtime Error #31892

Description

@amitavaghosh2

Checked other resources

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

from langchain_community.tools import DuckDuckGoSearchRun
from pydantic import Field


class SearchTool(BaseTool):
    name: str = "WebSearch"
    description: str = (
        "Useful for search-based queries. "
        "Use this to find current information about products, images and trends."
    )

    search: DuckDuckGoSearchRun = Field(default_factory=DuckDuckGoSearchRun)

    def _run(self, query: str) -> str:
        """Execute the search query and return results"""
        try:
            return self.search.invoke(query)
        except Exception as e:
            return f"Error performing search: {str(e)}. Fallback to ClassicSearchTool"
@CrewBase
class OneShotKrew:
    agents_config = "config/agents.yaml"
    tasks_config = "config/tasks.yaml"

    agents: List[BaseAgent]
    tasks: List[Task]

    ctx: CrewDeps

    def __init__(self, ctx: CrewDeps):
        self.ctx = ctx
        self.agents = []
        self.tasks = []

    def bootstrap(
        self,
        agent_key: str,
        output,
        extra_args: ExtraArgs = ExtraArgs(),
    ):
        agent_args: Dict[str, Any] = extra_args.agent_args or {}
        task_args: Dict[str, Any] = extra_args.task_args or {}

        curator_agent = Agent(
            config=self.agents_config[agent_key],  # type: ignore[index]
            verbose=self.ctx.debug,
            **agent_args,
        )

        curator_task = Task(
            config=self.tasks_config[agent_key],  # type: ignore[index]
            agent=curator_agent,
            output_pydantic=output,
            max_retries=2,
            # output_file=f"outputs/{agent_key}_result.md",
            **task_args,
        )

        self.agents.append(curator_agent)
        self.tasks.append(curator_task)

class ProductCategoryCurator(OneShotKrew):
    def __init__(self, ctx):
        super().__init__(ctx)

    def setup(self):
        self.bootstrap(
            CREW_KEY_CURATOR,
            ProductCategories,
            ExtraArgs(
                agent_args={
                    "tools": [
                        SearchTool(),
                        # ClassicSearchTool(),
                        # CSVReaderFromURLTool(),
                        # ScrapeWebsiteTool(),
                    ],
                    "llm": self.ctx.llm.load(LLMExecutorIntent),
                },
            ),
        )

        return self

    def crew(self):
        return Crew(
            agents=self.agents,
            tasks=self.tasks,
            verbose=self.ctx.debug,
            max_rpm=10,
        )

Error Message and Stack Trace (if applicable)

~/analyser/domainexpansion/.venv/lib/python3.12/site-packages/langchain_community/utilities/duckduckgo_search.py:63: RuntimeWarning: This package
(`duckduckgo_search`) has been renamed to `ddgs`! Use `pip install ddgs` instead.
  with DDGS() as ddgs:

Description

This was working alright, but probably something has changed, even after uv add --active ddgs, this doesn't go away.

System Info

[project]
name = "domainexpansion"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "crewai[tools]>=0.140.0",
    "ffmpeg-python>=0.2.0",
    "pydantic>=2.11.7",
    "scenedetect[opencv-headless]>=0.6.6",
    "yt-dlp>=2025.6.30",
    "commons",
    "python-ulid[pydantic]>=3.0.0",
    "pyzmq>=27.0.0",
    "aiosqlite>=0.21.0",
    "greenlet>=3.2.3",
    "ddgs>=9.0.0",
    "langchain-community>=0.3.27",
    "duckduckgo-search>=8.1.1",
]

[tool.uv.sources]
commons = { path = "../commons" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions