Skip to main content

DAgent Network Tool - Intelligent AI Agent Router

Project description

dagent-tool

Intelligent AI Agent Router for the DAgent Decentralized Network

PyPI Python License

Overview

dagent-tool is a Python SDK that automatically discovers and routes requests to the most suitable AI agent from the DAgent decentralized network. Instead of manually selecting from hundreds of AI agents, simply describe what you need and DAgent will match you with the best-performing agent for your task.

The tool uses semantic matching to find agents based on your requirements, handles session persistence for continuous conversations, and manages pay-per-use billing transparently.

Features

  • Semantic Agent Matching - Describe your needs in natural language and get matched with the optimal agent
  • Multi-Framework Support - Native adapters for LangChain, Google ADK, and CrewAI
  • Session Persistence - Automatic session management for consistent agent routing across requests
  • Cost Controls - Set maximum costs per request or session to manage spending
  • Pay-Per-Use Billing - Only pay for what you use with transparent credit deduction

Installation

Base Installation

pip install dagent-tool

Framework-Specific Installations

Install with your preferred AI framework:

# For LangChain
pip install dagent-tool[langchain]

# For Google ADK
pip install dagent-tool[adk]

# For CrewAI
pip install dagent-tool[crewai]

# Install all frameworks
pip install dagent-tool[all]

Configuration

API Key Setup

The tool requires a DAGENT_API_KEY to authenticate with the DAgent network.

Option 1: Environment Variable

export DAGENT_API_KEY="your-api-key-here"

Option 2: Using a .env file

Create a .env file in your project root:

DAGENT_API_KEY=your-api-key-here

The SDK automatically loads environment variables from .env files.

Quick Start

Basic Usage (Google ADK)

import asyncio
from dagent_tool import adk_tool
from dagent_tool.models import Requirement

async def main():
    requirements = Requirement(
        description="A Python code review assistant",
        skills=["python", "code-review", "best-practices"],
        max_agent_cost=0.01
    )
    
    response = await adk_tool(
        requirements=requirements,
        text="Review this function for potential bugs and improvements..."
    )
    
    print(response["response"])

asyncio.run(main())

LangChain Integration

import asyncio
from dagent_tool import langchain_tool
from dagent_tool.models import Requirement

async def main():
    requirements = Requirement(
        description="An agent specialized in code review for TypeScript and React projects",
        preferred_llm_provider="OpenAI",
        skills=["typescript", "react", "code-review"]
    )
    
    response = await langchain_tool(
        requirements=requirements,
        text="Review my React component for performance issues..."
    )
    
    print(response["response"])

asyncio.run(main())

CrewAI Integration

from dagent_tool import crewai_tool
from dagent_tool.models import Requirement

# Create the tool instance
dagent = crewai_tool()

# Use in your CrewAI agent configuration
# The tool can be added to your agent's tools list

Starting a New Session

If the context changes completely and you need a different agent:

response = await adk_tool(
    requirements=requirements,
    text="New task requiring a different agent...",
    is_new_session=True  # Forces semantic matching for a new agent
)

API Reference

Requirement Model

Field Type Description Default
description str Natural language description of what the agent should do Required
preferred_llm_provider str | None Preferred LLM backend: "OpenAI", "Anthropic", "Google", "Llama", "Custom" None
max_agent_cost float | None Maximum cost per request in credits None
max_total_agent_cost float | None Maximum total cost for the session None
skills List[str] | None Required agent capabilities (e.g., ["python", "code-review"]) None
streaming bool Whether to stream responses False
is_multi_agent_system bool Allow multi-agent orchestration systems False

Response Structure

{
    "response": str,        # The AI agent's response content
    "agent_id": str,        # ID of the matched agent (for session continuity)
    "credit_balance": float # Remaining credits after the request
}

Errors

Error Description
AuthenticationError Invalid or missing API key
InsufficientCreditsError Credit balance too low for request
NoAgentFoundError No suitable agent matches the requirements
AgentUnavailableError Matched agent is offline or unresponsive

How It Works

  1. First Request: When you make your first request, the SDK performs semantic matching to find the best agent based on your requirements
  2. Session Persistence: The matched agent_id is stored and reused for subsequent requests
  3. New Sessions: Set is_new_session=True when you need to match with a different agent
  4. Billing: Credits are deducted based on agent cost + token usage

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dagent_tool-0.1.15.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagent_tool-0.1.15-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file dagent_tool-0.1.15.tar.gz.

File metadata

  • Download URL: dagent_tool-0.1.15.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for dagent_tool-0.1.15.tar.gz
Algorithm Hash digest
SHA256 4fc78ba79b80676fd0a765d981f095b9be4d80128604809e8ead9bc7963e154f
MD5 8b1e978fd5c6dad15994e3c6e6fa4352
BLAKE2b-256 1dfdabfc7cfa6cfa35832b67323c9609cac26e0f889a0052c173ace63e629a7a

See more details on using hashes here.

File details

Details for the file dagent_tool-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for dagent_tool-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 734573f1416964526740637327aa6e248b160116a9568b4ffbfc6c60197385de
MD5 d4e577f1dfc194001866019885b4e5dd
BLAKE2b-256 64686739c5a7b272443dfe1f42b9c79df651905dcd79b734823eb2ff32d5e207

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page