Integrations
LangChain DeepAgents
Trace deep-research DeepAgents in Muster via the LangChain CallbackHandler.
DeepAgents is a LangChain-based framework for building autonomous AI agents that plan, research, critique, and iterate. Muster captures DeepAgents executions through the standard LangChain CallbackHandler.
Setup
1. Install dependencies
%pip install langfuse deepagents tavily-python2. Configure credentials
import os
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_HOST"] = "https://app.getmuster.io"
os.environ["ANTHROPIC_API_KEY"] = "sk-..."
os.environ["TAVILY_API_KEY"] = "tvly-..."3. Initialize the callback handler
from langfuse import get_client
from langfuse.langchain import CallbackHandler
langfuse = get_client()
if langfuse.auth_check():
print("Muster client is authenticated and ready!")
langfuse_handler = CallbackHandler()Example 1: simple research agent
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent
tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def internet_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
include_raw_content: bool = False,
):
return tavily_client.search(
query,
max_results=max_results,
include_raw_content=include_raw_content,
topic=topic,
)
agent = create_deep_agent(
tools=[internet_search],
system_prompt="You are an expert researcher.",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What is Muster and how does it help with LLM observability?"}]},
config={"callbacks": [langfuse_handler]},
)
Example 2: multi-agent with sub-agents
from deepagents import create_deep_agent
research_sub_agent = {
"name": "research-agent",
"description": "Used to research more in-depth questions.",
"system_prompt": "You are a dedicated researcher.",
"tools": [internet_search],
}
critique_sub_agent = {
"name": "critique-agent",
"description": "Critiques the final report.",
"system_prompt": "You are a dedicated editor.",
}
agent = create_deep_agent(
tools=[internet_search],
system_prompt="You are an expert researcher.",
subagents=[critique_sub_agent, research_sub_agent],
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What is Muster?"}]},
config={"callbacks": [langfuse_handler]},
)
The trace shows agent planning, sub-agent interactions, tool invocations (web searches), full conversation history, and per-step latencies.