Add reasoning_interval and adaptive_reasoning features

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-05-26 17:32:47 +00:00
parent 22db4aae81
commit 9a2ddb39ce
6 changed files with 595 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
"""
Example demonstrating the new reasoning interval and adaptive reasoning features.
This example shows how to:
1. Use reasoning_interval to make an agent reason every X steps
2. Use adaptive_reasoning to let the agent decide when to reason
"""
from crewai import Agent, Task, Crew
from crewai.tools import WebBrowserTool
browser_tool = WebBrowserTool()
interval_agent = Agent(
role="Research Analyst",
goal="Find and analyze information about a specific topic",
backstory="You are a skilled researcher who methodically analyzes information.",
verbose=True,
reasoning=True,
reasoning_interval=3,
tools=[browser_tool]
)
adaptive_agent = Agent(
role="Research Analyst",
goal="Find and analyze information about a specific topic",
backstory="You are a skilled researcher who methodically analyzes information.",
verbose=True,
reasoning=True,
adaptive_reasoning=True,
tools=[browser_tool]
)
research_task = Task(
description="""
Research the latest developments in renewable energy technology.
1. Find information about recent breakthroughs in solar energy
2. Research advancements in wind power technology
3. Analyze trends in energy storage solutions
4. Compare the cost-effectiveness of different renewable energy sources
5. Summarize your findings in a comprehensive report
""",
expected_output="A comprehensive report on the latest developments in renewable energy technology",
agent=interval_agent # Use the interval_agent for this example
)
crew = Crew(
agents=[interval_agent],
tasks=[research_task],
verbose=2
)
result = crew.kickoff()
print("\nResult:")
print(result)