Ran script in #222 in a fresh environment.
Errors with AttributeError: 'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'
Example Code
Version below changes how agents are passed to avoid deprecation warning (ran it both ways).
# uv pip install langchain-community, duckduckgo-search
import controlflow as cf
from langchain_community.tools import DuckDuckGoSearchRun
summarizer = cf.Agent(
name="Headline Summarizer",
description="An AI agent that fetches and summarizes current events",
tools=[DuckDuckGoSearchRun()],
)
extractor = cf.Agent(
name="Entity Extractor",
description="An AI agent that does named entity recognition",
)
@cf.flow
def get_headlines():
summarizer_task = cf.Task(
"Retrieve and summarize today's two top business headlines",
agent=summarizer,
result_type=list[str],
)
extractor_task = cf.Task(
"Extract any fortune 500 companies mentioned in the headlines and whether the sentiment is positive, neutral, or negative",
agent=extractor,
depends_on=[summarizer_task],
)
return summarizer_task, extractor_task
if __name__ == "__main__":
headlines, entity_sentiment = get_headlines()
print(headlines, entity_sentiment)
Version Information
Same package versions in working and non-working cases other than controlflow:
controflow 0.8.3.dev54+gc90dfbb
duckduckgo-search 6.1.12
langchain 0.2.7 pypi_0 pypi
langchain-anthropic 0.1.19 pypi_0 pypi
langchain-community 0.2.7 pypi_0 pypi
langchain-core 0.2.16 pypi_0 pypi
langchain-openai 0.1.15 pypi_0 pypi
langchain-text-splitters 0.2.2 pypi_0 pypi
Additional Context
09:49:07.241 | ERROR | Flow run 'cerulean-coyote' - Encountered exception during execution: AttributeError("'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'")
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 635, in run_context
yield self
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 676, in run_flow_sync
engine.call_flow_fn()
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 655, in call_flow_fn
result = call_with_parameters(self.flow.fn, self.parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/decorators.py", line 120, in wrapper
flow_obj.run()
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/flows/flow.py", line 134, in run
orchestrator.run(steps=steps)
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/orchestration/orchestrator.py", line 114, in run
agent._run(context=context)
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 202, in _run
for event in self._run_model(messages=messages, tools=context.tools):
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 227, in _run_model
model = self.get_model(tools=tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 159, in get_model
model = model.bind_tools([t.to_lc_tool() for t in tools])
^^^^^^^^^^^^
AttributeError: 'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'
09:49:07.370 | ERROR | Flow run 'cerulean-coyote' - Finished in state Failed("Flow run encountered an exception: AttributeError: 'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'")
Traceback (most recent call last):
File "/Users/jeffhale/Desktop/prefect/demos/cf/cf_example.py", line 38, in <module>
headlines, entity_sentiment = get_headlines()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flows.py", line 1326, in __call__
return run_flow(
^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 798, in run_flow
return run_flow_sync(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 678, in run_flow_sync
return engine.state if return_type == "state" else engine.result()
^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 243, in result
raise self._raised
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 635, in run_context
yield self
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 676, in run_flow_sync
engine.call_flow_fn()
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/flow_engine.py", line 655, in call_flow_fn
result = call_with_parameters(self.flow.fn, self.parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/decorators.py", line 120, in wrapper
flow_obj.run()
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/flows/flow.py", line 134, in run
orchestrator.run(steps=steps)
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/orchestration/orchestrator.py", line 114, in run
agent._run(context=context)
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 202, in _run
for event in self._run_model(messages=messages, tools=context.tools):
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 227, in _run_model
model = self.get_model(tools=tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/cfmain/lib/python3.12/site-packages/controlflow/agents/agent.py", line 159, in get_model
model = model.bind_tools([t.to_lc_tool() for t in tools])
^^^^^^^^^^^^
AttributeError: 'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'
Description
Ran script in #222 in a fresh environment. Errors with
AttributeError: 'DuckDuckGoSearchRun' object has no attribute 'to_lc_tool'
Example Code
Version Information
Additional Context