Multi-framework examples showcasing dagent-tool integration
This repository demonstrates how to integrate the DAgent decentralized network with popular AI agent frameworks. Each example shows how your agents can discover and route requests to specialized AI agents on-demand.
| Framework | Directory | Description |
|---|---|---|
| Google ADK | examples/adk/ | Native ADK agent with dagent-tool |
| LangChain | examples/langchain/ | LangChain agent with custom tool |
| CrewAI | examples/crewai/ | CrewAI agent with dagent integration |
Each example agent uses dagent-tool as a tool, allowing it to:
- Dynamically discover the best-suited agent from the DAgent network based on natural language requirements
- Route complex queries to specialized agents (code reviewers, data analysts, creative writers, etc.)
- Maintain session context across multiple interactions with the same remote agent
- Python 3.10+
- A DAgent API Key — for network authentication
- Framework-specific API keys (see each example)
git clone <your-repo-url>cd dagent_client
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate# For Google ADK
pip install dagent-tool[adk]
# For LangChain
pip install dagent-tool[langchain]
# For CrewAI
pip install dagent-tool[crewai]
# Install all frameworks
pip install dagent-tool[all]Create a .env file in the project root:
# Required for all examplesDAGENT_API_KEY=your-dagent-api-key# For Google ADK exampleGOOGLE_API_KEY=your-google-ai-api-key# For LangChain exampleOPENAI_API_KEY=your-openai-api-key# For CrewAI exampleOPENAI_API_KEY=your-openai-api-keydagent_client/
├── examples/
│ ├── adk/
│ │ ├── __init__.py
│ │ └── agent.py # Google ADK example
│ ├── langchain/
│ │ ├── __init__.py
│ │ └── agent.py # LangChain example
│ └── crewai/
│ ├── __init__.py
│ └── agent.py # CrewAI example
├── .env # API keys (create this)
└── README.md
adk run examples/adk
# Or use the web interface
adk webfromgoogle.adk.agents.llm_agentimportAgentfromdagent_toolimportadk_toolroot_agent=Agent(
model='gemini-2.5-flash',
name='root_agent',
description='A helpful assistant for user questions.',
instruction='Answer user questions and use adk_tool to connect with specialized agents when needed',
tools=[adk_tool]
)python examples/langchain/agent.pyimportasynciofromlangchain_openaiimportChatOpenAIfromlangchain.agentsimportAgentExecutor, create_openai_functions_agentfromlangchain_core.promptsimportChatPromptTemplate, MessagesPlaceholderfromdagent_toolimportlangchain_toolllm=ChatOpenAI(model="gpt-4o", temperature=0)
prompt=ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant. Use the dagent tool to connect with specialized agents when needed."),
("human", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
])
agent=create_openai_functions_agent(llm, [langchain_tool], prompt)
agent_executor=AgentExecutor(agent=agent, tools=[langchain_tool], verbose=True)
# Runresponse=agent_executor.invoke({"input": "Review this Python code for bugs..."})
print(response["output"])python examples/crewai/agent.pyfromcrewaiimportAgent, Task, Crewfromdagent_toolimportcrewai_tool# Create the dagent tool instancedagent=crewai_tool()
# Define agent with dagent toolresearcher=Agent(
role='Research Assistant',
goal='Help users by connecting to specialized agents when needed',
backstory='An intelligent assistant that can leverage the DAgent network for specialized tasks',
tools=[dagent],
verbose=True
)
# Create tasktask=Task(
description='Review this Python function for potential bugs: def add(a, b): return a - b',
agent=researcher,
expected_output='A detailed code review with identified issues and fixes'
)
# Run crewcrew=Crew(agents=[researcher], tasks=[task])
result=crew.kickoff()
print(result)Customize agent matching through the Requirement model:
fromdagent_tool.modelsimportRequirementrequirements=Requirement(
description="A Python code review assistant",
skills=["python", "code-review", "best-practices"],
preferred_llm_provider="OpenAI", # OpenAI, Anthropic, Google, Llama, Custommax_agent_cost=0.01, # Per-request cost limitmax_total_agent_cost=1.0, # Session cost limitstreaming=False,
is_multi_agent_system=False
)Once running, try prompts like:
| Prompt | What Happens |
|---|---|
"Review this Python function for bugs: def add(a,b): return a-b" | Routes to a code review specialist |
| "Write a haiku about distributed systems" | Routes to a creative writing agent |
| "Explain the CAP theorem in simple terms" | May answer directly or route to a technical explainer |
| Issue | Solution |
|---|---|
AuthenticationError | Check your DAGENT_API_KEY is valid |
InsufficientCreditsError | Top up credits at dagent.network |
NoAgentFoundError | Broaden your requirements or remove skill constraints |
ModuleNotFoundError: google.adk | Run pip install dagent-tool[adk] |
ModuleNotFoundError: langchain | Run pip install dagent-tool[langchain] |
ModuleNotFoundError: crewai | Run pip install dagent-tool[crewai] |
- dagent-tool on PyPI — Full SDK documentation
- Google ADK Docs — Agent Development Kit reference
- LangChain Docs — LangChain framework reference
- CrewAI Docs — CrewAI framework reference
- DAgent Network — Get API keys and explore available agents
MIT