LangChain & DeepAgents

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.

Prerequisites

  • InteractiveAI account with API credentials

  • Anthropic API key

  • Web search API (e.g.: Tavily)

  • Python 3.11 or higher


Installation

pip install interactiveai deepagents tavily-python

Configuration

Initialize the client and the CallbackHandler:

import os
from dotenv import load_dotenv

load_dotenv()

from interactiveai import Interactive
from interactiveai.langchain import CallbackHandler

interactiveai = Interactive(
    public_key=os.getenv("INTERACTIVEAI_PUBLIC_KEY"),
    secret_key=os.getenv("INTERACTIVEAI_SECRET_KEY"),
)

handler = CallbackHandler()

if interactiveai.auth_check():
    print("Connection established")
else:
    print("Authentication failed - verify credentials")

Create a research agent that can search the web and synthesize information:

Example 2: Multi-Agent Research Pipeline

Create a sophisticated agent with specialized sub-agents for research and review:


Enriching Traces with Context

Add user tracking and metadata to your DeepAgents traces:


Trace Visibility

After execution, the InteractiveAI dashboard displays:

  • Complete agent execution flow including planning steps

  • Sub-agent interactions and handoffs

  • Tool invocations (web searches) with results

  • Token usage across all agent calls

  • Full reasoning chain for debugging

  • Cost and latency metrics per step

Last updated

Was this helpful?