Skip to main content

consul-adk

Project description

consul-adk

This is an AI Agent Development Kit(ADK) built on top of Google ADK to implement Agentic Service Mesh. Using this and Consul CE/ENT, you can discover and scale the Agents and MCP servers and create a desired agent graph using Service intentions. The ADK help to create the desired client's for the Agents and MCP servers as soon as the intentions are defined in Consul.

Installation

pip install consul-adk

Usage Example

Below is a simple example to get you started:

A simple agent with hardcoded instructions

# 🧠 Gemini-based AI agent provided by Google's ADK
from google.adk.agents.llm_agent import LlmAgent
from google.adk.tools import FunctionTool
from utilities.consul_agent import ConsulEnabledAIAgent

class WeatherAgent(ConsulEnabledAIAgent):

    def build_agent(self) -> LlmAgent:
        """
        ⚙️ Creates and configures a Gemini agent with weather capabilities.

        Returns:
            LlmAgent: A configured agent object from Google's ADK
        """
        # Manually adding the WeatherTool to the agent's tools
        tools = [
            FunctionTool(WeatherTool(name="WeatherTool", description="Gets the realtime weather for one or more locations").get_weather)
        ]

        # Automatically add MCP tools as they are registered in Consul and Intentions are defined
        for tool_set in self._remote_mcp_tools.values():
            tools.append(tool_set)

        return LlmAgent(
            model="gemini-1.5-flash-latest",  # Gemini model version
            name="weather_agent",  # Name of the agent
            description="Provides weather information for multiple locations",  # Description for metadata
            instruction="You are a helpful weather assistant. When asked about weather, extract the 'locations' parameter as a list (even for a single location), then use the 'WeatherTool' to provide weather information. When multiple locations are requested, organize your response clearly with headings for each location. Be friendly and informative. If user asks for locations with specific weather conditions, first get weather for several cities in that region, then recommend ones that match the criteria.",
            # System prompt
            tools=tools,
        )
from google.adk.tools import BaseTool
class WeatherTool(BaseTool):
    """A tool that provides weather information for multiple locations.

    Attributes:
        name: The name of the tool.
        description: A brief description of what the tool does.
    """
    name = "WeatherTool"
    description = "Gets the current weather information for one or more specified locations"

    async def get_weather(self, locations: List[str]) -> List[dict[str, Any]]:
        # Hey developer, implement the logic to fetch weather data here

An orchestrator agent which adapts its instructions by reading the child-agent card.

class OrchestratorAgent(ConsulEnabledAIAgent):

    def build_agent(self) -> LlmAgent:
        """
        Construct the Gemini-based LlmAgent with tools
        """
        tools = [
            self._list_agents, # built-in tool to list all registered agents
            self._agent_skills, # built-in tool to list all skills of a specific agent
            self._delegate_task, # built-in tool to delegate tasks to other agents
            self._tell_time # built-in tool to tell the current time
        ]
        # Automatically add MCP tools as they are registered in Consul and Intentions are defined
        for tool_set in self._remote_mcp_tools.values():
            # Add each MCPToolset to the agent's tools
            tools.append(tool_set)

        ai_agent = LlmAgent(
            model="gemini-1.5-flash-latest",
            name="orchestrator_agent",
            description="Delegates user queries to child A2A agents based on intent.",
            instruction=self._root_instruction, # dynamically generated instruction based on current state of the child agents
            tools=tools
        )

        return ai_agent

Features

  • Auto discover AI agents and creates their client connections in this agent as soon as Consul intentions are defined
  • Auto-configure agents and MCP servers
  • Send and manage tasks between agents

Documentation

For more details, see the internal.md or explore the client/, models/, and server/ directories.

Contributing

We welcome contributions! Please read our contributing guidelines for details on how to get started.

Please run below command to ensure your code compiles before it is submitted:

python -m build

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

consul_adk-0.0.6.tar.gz (32.5 kB view details)

Uploaded Source

Built Distribution

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

consul_adk-0.0.6-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file consul_adk-0.0.6.tar.gz.

File metadata

  • Download URL: consul_adk-0.0.6.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for consul_adk-0.0.6.tar.gz
Algorithm Hash digest
SHA256 50ec50edb495f5030e416b7940e5bd0c7594c9e84635b39b4300ec9a1c43265a
MD5 324084b8fa31a19aa5a73e63c0e1b3d1
BLAKE2b-256 3246b1494cc3e1875e70dc5598cfd74f0a270a7f605dc1003746fc5afd701c7d

See more details on using hashes here.

File details

Details for the file consul_adk-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: consul_adk-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for consul_adk-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 75c653d30fe5b26410dcfca236f147fe742b4e02dd329cc97e72e5be3aa99d5c
MD5 48de50c0ad6e106e4b12ce286991c5c7
BLAKE2b-256 3256a3a5f269a5c03376d0f2ca6b925a1b53337186da32fad8d3f0d76ebf933c

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