agentconnect.agents.ai_agent module¶
Independent AI Agent implementation for the AgentConnect decentralized framework.
This module provides an autonomous AI agent that can operate independently within a decentralized network, process messages, generate responses, discover other agents based on capabilities, and interact with those agents without pre-defined connections or central control. Each agent can potentially implement its own internal multi-agent structure while maintaining secure communication with other agents in the decentralized network.
- class AIAgent(agent_id, name, provider_type, model_name, api_key, identity, capabilities=None, personality='helpful and professional', organization_id=None, interaction_modes=[InteractionMode.HUMAN_TO_AGENT, InteractionMode.AGENT_TO_AGENT], max_tokens_per_minute=5500, max_tokens_per_hour=100000, is_ui_mode=False, memory_type=MemoryType.BUFFER, prompt_tools=None, prompt_templates=None, custom_tools=None, agent_type='ai')¶
Bases:
BaseAgent
Independent AI Agent implementation that operates autonomously in a decentralized network.
This agent uses language models to generate responses, can discover and communicate with other agents based on their capabilities (not pre-defined connections), and can implement its own internal multi-agent structure if needed. It operates as a peer in a decentralized system rather than as part of a centrally controlled hierarchy.
Key features:
Autonomous operation with independent decision-making
Capability-based discovery of other agents
Secure identity verification and communication
Potential for internal multi-agent structures
Dynamic request routing based on capabilities
- Parameters:
agent_id (str)
name (str)
provider_type (ModelProvider)
model_name (ModelName)
api_key (str)
identity (AgentIdentity)
capabilities (List[Capability])
personality (str)
organization_id (str | None)
interaction_modes (List[InteractionMode])
max_tokens_per_minute (int)
max_tokens_per_hour (int)
is_ui_mode (bool)
memory_type (MemoryType)
prompt_tools (PromptTools | None)
prompt_templates (PromptTemplates | None)
custom_tools (List[BaseTool] | None)
agent_type (str)
- property hub¶
Get the hub property.
- property registry¶
Get the registry property.
- async process_message(message)¶
Process an incoming message autonomously and generate a response.
This method represents the agent’s autonomous decision loop, where it: :rtype:
Optional
[Message
]Verifies message security independently
Makes decisions on how to respond based on capabilities
Can dynamically discover and collaborate with other agents as needed
Maintains its own internal state and conversation tracking
Operates without central coordination or control
The agent can leverage its internal workflow (which may include its own multi-agent system) to generate appropriate responses and handle complex tasks that may require collaboration with other independent agents in the decentralized network.
- property prompt_tools¶
Get the prompt_tools property.
- set_cooldown(duration)¶
Set a cooldown period for the agent.