DeepAgents is a framework for building autonomous AI agents that can perform deep research and complex tasks. Built on LangChain, DeepAgents provides tools for creating agents that can plan, research, critique, and iterate on their outputs.
InteractiveAI integrates with LangChain DeepAgents using the built-in CallbackHandler. The SDK automatically captures detailed traces of your DeepAgents executions, including planning steps, research iterations, tool calls, and sub-agent interactions.
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent
tavily = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def web_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
) -> dict:
"""Search the web for information."""
return tavily.search(query, max_results=max_results, topic=topic)
system_prompt = """You are an expert analyst. Your job is to research topics thoroughly and provide clear, actionable insights.
You have access to a web search tool. Use it to gather current information before forming your analysis.
Structure your responses with:
1. Key findings
2. Supporting evidence
3. Recommendations
"""
agent = create_deep_agent(
tools=[web_search],
system_prompt=system_prompt,
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What are the latest trends in AI agent frameworks?"}]},
config={"callbacks": [handler]}
)
print(result)
client.flush()
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent
tavily = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def web_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
) -> dict:
"""Search the web for information."""
return tavily.search(query, max_results=max_results, topic=topic)
# Sub-agent for focused research
research_agent = {
"name": "researcher",
"description": "Conducts deep research on a specific topic. Give this agent one focused question at a time.",
"system_prompt": """You are a dedicated researcher. Conduct thorough research using the search tool and provide detailed findings.
Your final message should contain all relevant information - the user will only see your final response.""",
"tools": [web_search],
}
# Sub-agent for quality review
review_agent = {
"name": "reviewer",
"description": "Reviews and critiques research reports for completeness and accuracy.",
"system_prompt": """You are a quality reviewer. Evaluate reports for:
- Completeness of coverage
- Accuracy of claims
- Clarity of presentation
- Missing perspectives
Provide specific, actionable feedback.""",
}
# Main orchestrator agent
orchestrator_prompt = """You are a research director coordinating a team of specialists.
Your workflow:
1. Break down complex questions into focused research tasks
2. Delegate to the researcher agent for each topic
3. Compile findings into a comprehensive report
4. Send to the reviewer agent for quality check
5. Iterate based on feedback until satisfied
Write your final report in clear markdown with proper citations.
"""
agent = create_deep_agent(
tools=[web_search],
system_prompt=orchestrator_prompt,
subagents=[research_agent, review_agent],
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Compare the architectural approaches of CrewAI, AutoGen, and LangGraph for building multi-agent systems."}]},
config={"callbacks": [handler]}
)
print(result)
client.flush()
import os
from dotenv import load_dotenv
from typing import Literal
load_dotenv()
from interactiveai import Interactive
from interactiveai.langchain import CallbackHandler
from tavily import TavilyClient
from deepagents import create_deep_agent
client = Interactive(
public_key=os.getenv("INTERACTIVEAI_PUBLIC_KEY"),
secret_key=os.getenv("INTERACTIVEAI_SECRET_KEY"),
host=os.getenv("INTERACTIVEAI_HOST", "https://app.interactive.ai"),
)
handler = CallbackHandler()
tavily = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def web_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
) -> dict:
"""Search the web for information."""
return tavily.search(query, max_results=max_results, topic=topic)
agent = create_deep_agent(
tools=[web_search],
system_prompt="You are a helpful research assistant with web search capabilities.",
)
with client.start_as_current_span(name="deepagents-research") as span:
client.update_current_trace(
user_id="user_456",
session_id="session_xyz",
tags=["deepagents", "research"],
metadata={"use_case": "competitive-analysis", "environment": "production"}
)
query = "What are the key differences between vector databases Pinecone, Weaviate, and Chroma?"
result = agent.invoke(
{"messages": [{"role": "user", "content": query}]},
config={"callbacks": [handler]}
)
span.update(
input={"query": query},
output={"result": str(result)}
)
client.flush()