agentconnect.core package¶
Core components for the AgentConnect framework.
This module provides the foundational building blocks for agent-based systems in the decentralized AgentConnect framework, including:
Base Agent: Abstract base class for all agent implementations
Message Handling: Secure, signed message creation and verification
Agent Identity: Decentralized identity and cryptographic verification
Capability Registry: Dynamic discovery of agent capabilities
Type System: Rich type definitions for the entire framework
The core module focuses on establishing the foundation for decentralized agent interaction without imposing centralized control structures.
- class Message(id, sender_id, receiver_id, content, message_type, timestamp, metadata=<factory>, protocol_version=ProtocolVersion.V1_0, signature=None)¶
Bases:
objectMessage class for agent communication.
This class represents messages exchanged between agents, with support for content, metadata, and cryptographic signatures for verification.
- Parameters:
id (str)
sender_id (str)
receiver_id (str)
content (str)
message_type (MessageType)
timestamp (datetime)
metadata (Dict)
protocol_version (ProtocolVersion)
signature (str | None)
- id¶
Unique identifier for the message
- sender_id¶
ID of the sending agent
- receiver_id¶
ID of the receiving agent
- content¶
Message content
- message_type¶
Type of message (text, command, response, etc.)
- timestamp¶
When the message was created
- metadata¶
Additional information about the message
- protocol_version¶
Version of the communication protocol
- signature¶
Cryptographic signature for verification
- classmethod create(sender_id, receiver_id, content, sender_identity, message_type=MessageType.TEXT, metadata=None)¶
Create a new signed message.
- Parameters:
sender_id (
str) – ID of the sending agentreceiver_id (
str) – ID of the receiving agentcontent (
str) – Message contentsender_identity (
AgentIdentity) – Identity of the sending agentmessage_type (
MessageType) – Type of message being sentmetadata (
Optional[Dict]) – Additional information about the message
- Return type:
- Returns:
A signed Message object
- Raises:
ValueError – If the sender identity doesn’t have a private key for signing
-
protocol_version:
ProtocolVersion= '1.0'¶
- sign(identity)¶
Sign message with sender’s private key.
- Parameters:
identity (
AgentIdentity) – The identity containing the private key for signing- Raises:
ValueError – If the identity doesn’t have a private key
- Return type:
- verify(sender_identity)¶
Verify message signature using sender’s public key.
- Parameters:
sender_identity (
AgentIdentity) – The identity containing the public key for verification- Return type:
- Returns:
True if the signature is valid, False otherwise
- Raises:
SecurityError – If the sender identity is not verified
-
message_type:
MessageType¶
- class AgentType(value)¶
-
Types of agents in the system.
This enum defines the different types of agents that can exist in the system.
- HUMAN = 'human'¶
- AI = 'ai'¶
- class Capability(name, description, input_schema=None, output_schema=None, version='1.0')¶
Bases:
objectCapability definition for agents.
This class defines a capability that an agent can provide, including its name, description, and input/output schemas.
- Parameters:
- name¶
Name of the capability
- description¶
Description of what the capability does
- input_schema¶
Schema for the input data
- output_schema¶
Schema for the output data
- version¶
Version of the capability
- class AgentIdentity(did, public_key, private_key=None, verification_status=VerificationStatus.PENDING, created_at=<factory>, metadata=<factory>)¶
Bases:
objectDecentralized Identity for Agents.
This class provides identity management for agents, including cryptographic keys for signing and verification.
- Parameters:
- did¶
Decentralized Identifier
- public_key¶
Public key for verification
- private_key¶
Private key for signing (optional)
- verification_status¶
Status of identity verification
- created_at¶
When the identity was created
- metadata¶
Additional information about the identity
- classmethod create_key_based()¶
Create a new key-based identity for an agent.
This method generates a new RSA key pair and creates a key-based decentralized identifier (DID) for the agent.
- Return type:
- Returns:
A new AgentIdentity with generated keys and DID
- classmethod from_dict(data)¶
Create identity from dictionary format.
- Parameters:
data (
Dict) – Dictionary containing identity data- Return type:
- Returns:
AgentIdentity instance created from the dictionary
- sign_message(message)¶
Sign a message using the private key.
- Parameters:
message (
str) – The message to sign- Return type:
- Returns:
Base64-encoded signature
- Raises:
ValueError – If the private key is not available
- to_dict()¶
Convert identity to dictionary format.
- Return type:
- Returns:
Dictionary representation of the identity
-
verification_status:
VerificationStatus= 'pending'¶
- verify_signature(message, signature)¶
Verify a message signature using the public key.
- class InteractionMode(value)¶
-
Supported interaction modes between agents.
This enum defines the different ways agents can interact with each other.
- HUMAN_TO_AGENT = 'human_to_agent'¶
- AGENT_TO_AGENT = 'agent_to_agent'¶
- class ModelProvider(value)¶
-
Supported AI model providers.
This enum defines the supported model providers for AI agents.
- OPENAI = 'openai'¶
- ANTHROPIC = 'anthropic'¶
- GROQ = 'groq'¶
- GOOGLE = 'google'¶
- class ModelName(value)¶
-
Supported model names for each provider.
This enum defines the specific model names available for each provider.
- classmethod get_default_for_provider(provider)¶
Get the default model for a given provider.
- Parameters:
provider (
ModelProvider) – The model provider to get the default model for- Return type:
- Returns:
The default model name for the provider
- Raises:
ValueError – If no default model is defined for the provider
- GPT4_5_PREVIEW = 'gpt-4.5-preview-2025-02-27'¶
- GPT4_1 = 'gpt-4.1'¶
- GPT4_1_MINI = 'gpt-4.1-mini'¶
- GPT4O = 'gpt-4o'¶
- GPT4O_MINI = 'gpt-4o-mini'¶
- O1 = 'o1'¶
- O1_MINI = 'o1-mini'¶
- O3 = 'o3'¶
- O3_MINI = 'o3-mini'¶
- O4_MINI = 'o4-mini'¶
- CLAUDE_3_7_SONNET = 'claude-3-7-sonnet-latest'¶
- CLAUDE_3_5_SONNET = 'claude-3-5-sonnet-latest'¶
- CLAUDE_3_5_HAIKU = 'claude-3-5-haiku-latest'¶
- CLAUDE_3_OPUS = 'claude-3-opus-latest'¶
- CLAUDE_3_SONNET = 'claude-3-sonnet-20240229'¶
- CLAUDE_3_HAIKU = 'claude-3-haiku-20240307'¶
- LLAMA33_70B_VTL = 'llama-3.3-70b-versatile'¶
- LLAMA3_1_8B_INSTANT = 'llama-3.1-8b-instant'¶
- LLAMA_GUARD3_8B = 'llama-guard-3-8b'¶
- LLAMA3_70B = 'llama3-70b-8192'¶
- LLAMA3_8B = 'llama3-8b-8192'¶
- MIXTRAL = 'mixtral-8x7b-32768'¶
- GEMMA2_90B = 'gemma2-9b-it'¶
- GEMINI2_5_PRO = 'gemini-2.5-pro'¶
- GEMINI2_5_FLASH = 'gemini-2.5-flash'¶
- GEMINI2_5_FLASH_LITE = 'gemini-2.5-flash-lite'¶
- GEMINI2_FLASH = 'gemini-2.0-flash'¶
- GEMINI2_FLASH_LITE = 'gemini-2.0-flash-lite'¶
- GEMINI2_PRO_EXP = 'gemini-2.0-pro-exp-02-05'¶
- GEMINI2_FLASH_THINKING_EXP = 'gemini-2.0-flash-thinking-exp-01-21'¶
- class AgentProfile(**data)¶
Bases:
BaseModelComprehensive profile for an agent.
This class provides a complete profile of an agent, including its capabilities, skills, and other metadata needed for discovery and interaction.
- Parameters:
agent_id (str)
agent_type (AgentType)
name (str | None)
summary (str | None)
description (str | None)
version (str | None)
documentation_url (str | None)
organization (str | None)
developer (str | None)
url (str | None)
capabilities (List[Capability])
payment_address (str | None)
reputation_score (float | None)
- agent_id¶
Unique identifier for the agent
- agent_type¶
Type of agent (human, AI)
- name¶
Name of the agent
- summary¶
Brief summary of the agent’s purpose
- description¶
Detailed description of the agent
- version¶
Version of the agent
- documentation_url¶
URL to the agent’s documentation
- organization¶
Organization or entity providing the agent (e.g., ‘Acme Corp’, ‘did:org:123’). Using a verifiable ID is recommended for robustness.
- developer¶
Individual or team that developed the agent (e.g., ‘Alice’, ‘did:person:abc’). Using a verifiable ID is recommended.
- url¶
Endpoint URL for the agent
- auth_schemes¶
List of supported authentication schemes
- default_input_modes¶
List of supported input modes
- default_output_modes¶
List of supported output modes
- capabilities¶
List of capabilities the agent provides
- skills¶
List of skills the agent possesses
- examples¶
Example inputs/outputs or use cases
- tags¶
Keywords for filtering
- payment_address¶
Agent’s primary wallet address for receiving payments
- custom_metadata¶
Additional custom metadata about the agent
- reputation_score¶
Optional reputation score (excluded from serialization)
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
capabilities:
List[Capability]¶
- class Skill(**data)¶
Bases:
BaseModelSkill model for agents.
This class defines a skill that an agent can possess, including its name and description.
- name¶
Name of the skill
- description¶
Optional description of what the skill entails
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class AgentRegistry(vector_search_config=None)¶
Bases:
objectCentral registry for agent registration and discovery.
This class provides methods for registering agents, discovering agents by capability, and verifying agent identities.
- Parameters:
vector_search_config (VectorSearchSettings | Dict[str, Any] | None)
- async ensure_initialized()¶
Wait until the core registry initialization is complete.
- async get_agent_type(agent_id)¶
Get the type of an agent.
- async get_all_agents()¶
Get a list of all agents registered in the system.
- Return type:
- Returns:
List of all agent registrations
- async get_all_capabilities()¶
Get a list of all unique capability names registered in the system.
- async get_by_capability(capability_name, limit=10, similarity_threshold=0.1)¶
Find agents by capability name.
- Parameters:
- Return type:
- Returns:
List of agent registrations with the specified capability
- async get_by_capability_semantic(capability_description, limit=10, similarity_threshold=0.1, filters=None)¶
Find agents by capability description using semantic search.
- Parameters:
capability_description (
str) – Description of the capability to search forlimit (
int) – Maximum number of results to return (default: 10)similarity_threshold (
float) – Minimum similarity score to include in results (default: 0.1)filters (
Optional[Dict[str,List[str]]]) – Optional dictionary for filtering. Keys can include “tags”, “organization”, “developer”, “default_input_modes”, “default_output_modes”, “auth_schemes”. Values are lists of strings to match for the respective key.
- Return type:
- Returns:
List of tuples containing agent registrations and similarity scores
- async get_by_interaction_mode(mode)¶
Find agents by interaction mode.
- Parameters:
mode (
InteractionMode) – Interaction mode to search for- Return type:
- Returns:
List of agent registrations with the specified interaction mode
- async get_by_organization(organization)¶
Find agents by organization.
- Parameters:
organization (
str) – ID/name of the organization- Return type:
- Returns:
List of agent registrations in the specified organization
- async get_by_owner(owner_id)¶
Find agents by owner.
- Parameters:
owner_id (
str) – ID of the owner (now using developer field)- Return type:
- Returns:
List of agent registrations owned by the specified owner
- async get_registration(agent_id)¶
Get agent registration details.
- Parameters:
agent_id (
str) – ID of the agent- Return type:
- Returns:
Agent registration if found, None otherwise
- async get_verified_agents()¶
Get all verified agents.
- Return type:
- Returns:
List of verified agent registrations
- async register(registration)¶
Register a new agent with verification. Waits for initialization first.
- Parameters:
registration (
AgentRegistration) – Registration information for the agent- Return type:
- Returns:
True if registration was successful, False otherwise
- async unregister(agent_id)¶
Remove agent from registry.
- async update_registration(agent_id, updates)¶
Update agent registration details.
- Parameters:
- Return type:
- Returns:
Updated agent registration if successful, None otherwise
- property vector_search_settings: VectorSearchSettings¶
Get the vector search settings as a Pydantic model.
- async verify_agent(agent_id)¶
Verify an agent’s identity.
- class BaseAgent(agent_id, identity, interaction_modes, profile, enable_payments=False, wallet_data_dir=None)¶
Bases:
ABCAbstract base class for all agents in the system.
This class defines the core functionality that all agents must implement, including identity verification, message handling, and conversation management.
- Parameters:
agent_id (str)
identity (AgentIdentity)
interaction_modes (List[InteractionMode])
profile (AgentProfile)
enable_payments (bool)
wallet_data_dir (Optional[Union[str, Path]])
- agent_id¶
Unique identifier for the agent
- identity¶
Agent’s decentralized identity
- profile¶
Comprehensive profile for the agent
- capabilities¶
List of agent capabilities
- message_queue¶
Queue for incoming messages
- message_history¶
History of messages sent and received
- is_running¶
Whether the agent is currently running
- registry¶
Reference to the agent registry
- hub¶
Reference to the communication hub
- active_conversations¶
Dictionary of active conversations
- cooldown_until¶
Timestamp when cooldown ends
- pending_requests¶
Dictionary of pending requests
- enable_payments¶
Whether payment capabilities are enabled
- wallet_provider¶
Wallet provider for blockchain transactions
- agent_kit¶
AgentKit instance for blockchain actions
- async can_receive_message(sender_id)¶
Check if the agent can receive a message from the sender.
- async can_send_message(receiver_id)¶
Check if agent can send message.
- end_conversation(other_agent_id)¶
End conversation with another agent.
- is_in_cooldown()¶
Check if agent is in cooldown.
- Return type:
- Returns:
True if the agent is in cooldown, False otherwise
- async join_network(network)¶
Join an agent network for agent-to-agent communication.
Note: Join_network is not required for MVP The registry handles all agent discovery and communication We keep it for future network functionality
- Parameters:
network – The network to join
- Returns:
True if successfully joined, False otherwise
- property payments_enabled: bool¶
Check if payment capabilities are enabled and available.
- Returns:
True if payment capabilities are enabled and available, False otherwise
- abstractmethod async process_message(message)¶
Process incoming message - must be implemented by subclasses.
This method processes an incoming message and generates a response. It must be implemented by subclasses to provide agent-specific message processing logic.
- async receive_message(message)¶
Receive and queue a message.
- Parameters:
message (
Message) – The message to receive
- reset_cooldown()¶
Reset the cooldown state of the agent.
This method resets the agent’s cooldown state, allowing it to send and receive messages immediately.
- Return type:
- async run()¶
Start the agent’s message processing loop.
This method starts the agent’s main processing loop, which continuously processes messages from the message queue until the agent is stopped.
- async send_message(receiver_id, content, message_type=MessageType.TEXT, metadata=None)¶
Create and send a message through the hub.
- Parameters:
receiver_id (
str) – ID of the receiving agentcontent (
str) – Message contentmessage_type (
MessageType) – Type of message being sentmetadata (
Optional[Dict]) – Additional information about the message
- Return type:
- Returns:
The sent message
- Raises:
RuntimeError – If the agent is not registered with a hub
ValueError – If the message cannot be routed
- set_cooldown(duration)¶
Set a cooldown period for the agent.
- async stop()¶
Stop the agent and cleanup resources.
This method stops the agent’s processing loop, ends all active conversations, and cleans up resources such as wallet providers and message queues.
- Return type:
- Returns:
None
- async verify_identity()¶
Verify agent’s DID and update verification status.
This method verifies the agent’s decentralized identifier and updates the verification status accordingly.
- Return type:
- Returns:
True if the identity is verified, False otherwise
- Raises:
SecurityError – If identity verification fails
Subpackages¶
- agentconnect.core.registry package
AgentRegistryAgentRegistry.ensure_initialized()AgentRegistry.get_agent_type()AgentRegistry.get_all_agents()AgentRegistry.get_all_capabilities()AgentRegistry.get_by_capability()AgentRegistry.get_by_capability_semantic()AgentRegistry.get_by_interaction_mode()AgentRegistry.get_by_organization()AgentRegistry.get_by_owner()AgentRegistry.get_registration()AgentRegistry.get_verified_agents()AgentRegistry.register()AgentRegistry.unregister()AgentRegistry.update_registration()AgentRegistry.vector_search_settingsAgentRegistry.verify_agent()AgentRegistry.verify_owner()
AgentRegistrationAgentRegistration.agent_idAgentRegistration.agent_typeAgentRegistration.interaction_modesAgentRegistration.identityAgentRegistration.nameAgentRegistration.summaryAgentRegistration.descriptionAgentRegistration.versionAgentRegistration.documentation_urlAgentRegistration.organizationAgentRegistration.developerAgentRegistration.urlAgentRegistration.auth_schemesAgentRegistration.default_input_modesAgentRegistration.default_output_modesAgentRegistration.capabilitiesAgentRegistration.skillsAgentRegistration.examplesAgentRegistration.tagsAgentRegistration.payment_addressAgentRegistration.custom_metadataAgentRegistration.registered_atAgentRegistration.model_configAgentRegistration.agent_idAgentRegistration.agent_typeAgentRegistration.interaction_modesAgentRegistration.identityAgentRegistration.nameAgentRegistration.summaryAgentRegistration.descriptionAgentRegistration.versionAgentRegistration.documentation_urlAgentRegistration.organizationAgentRegistration.developerAgentRegistration.urlAgentRegistration.auth_schemesAgentRegistration.default_input_modesAgentRegistration.default_output_modesAgentRegistration.capabilitiesAgentRegistration.skillsAgentRegistration.examplesAgentRegistration.tagsAgentRegistration.payment_addressAgentRegistration.custom_metadataAgentRegistration.registered_at
CapabilityDiscoveryServiceCapabilityDiscoveryService.COLLECTION_NAMECapabilityDiscoveryService.clear_agent_embeddings_cache()CapabilityDiscoveryService.find_by_capability_name()CapabilityDiscoveryService.find_by_capability_semantic()CapabilityDiscoveryService.initialize_embeddings_model()CapabilityDiscoveryService.precompute_all_capability_embeddings()CapabilityDiscoveryService.update_capability_embeddings_cache()
- Subpackages
- Submodules
Submodules¶
- agentconnect.core.agent module
BaseAgentBaseAgent.agent_idBaseAgent.identityBaseAgent.profileBaseAgent.capabilitiesBaseAgent.message_queueBaseAgent.message_historyBaseAgent.is_runningBaseAgent.registryBaseAgent.hubBaseAgent.active_conversationsBaseAgent.cooldown_untilBaseAgent.pending_requestsBaseAgent.enable_paymentsBaseAgent.wallet_providerBaseAgent.agent_kitBaseAgent.payments_enabledBaseAgent.verify_identity()BaseAgent.send_message()BaseAgent.receive_message()BaseAgent.process_message()BaseAgent.run()BaseAgent.join_network()BaseAgent.set_cooldown()BaseAgent.is_in_cooldown()BaseAgent.end_conversation()BaseAgent.can_send_message()BaseAgent.can_receive_message()BaseAgent.stop()BaseAgent.reset_cooldown()
- agentconnect.core.exceptions module
- agentconnect.core.message module
MessageMessage.idMessage.sender_idMessage.receiver_idMessage.contentMessage.message_typeMessage.timestampMessage.metadataMessage.protocol_versionMessage.signatureMessage.idMessage.sender_idMessage.receiver_idMessage.contentMessage.message_typeMessage.timestampMessage.metadataMessage.protocol_versionMessage.signatureMessage.create()Message.sign()Message.verify()
- agentconnect.core.types module
ModelProviderModelNameModelName.GPT4_5_PREVIEWModelName.GPT4_1ModelName.GPT4_1_MINIModelName.GPT4OModelName.GPT4O_MINIModelName.O1ModelName.O1_MINIModelName.O3ModelName.O3_MINIModelName.O4_MINIModelName.CLAUDE_3_7_SONNETModelName.CLAUDE_3_5_SONNETModelName.CLAUDE_3_5_HAIKUModelName.CLAUDE_3_OPUSModelName.CLAUDE_3_SONNETModelName.CLAUDE_3_HAIKUModelName.LLAMA33_70B_VTLModelName.LLAMA3_1_8B_INSTANTModelName.LLAMA_GUARD3_8BModelName.LLAMA3_70BModelName.LLAMA3_8BModelName.MIXTRALModelName.GEMMA2_90BModelName.GEMINI2_5_PROModelName.GEMINI2_5_FLASHModelName.GEMINI2_5_FLASH_LITEModelName.GEMINI2_FLASHModelName.GEMINI2_FLASH_LITEModelName.GEMINI2_PRO_EXPModelName.GEMINI2_FLASH_THINKING_EXPModelName.get_default_for_provider()
AgentTypeInteractionModeProtocolVersionVerificationStatusCapabilityAgentIdentityAgentIdentity.didAgentIdentity.public_keyAgentIdentity.private_keyAgentIdentity.verification_statusAgentIdentity.created_atAgentIdentity.metadataAgentIdentity.didAgentIdentity.public_keyAgentIdentity.private_keyAgentIdentity.verification_statusAgentIdentity.created_atAgentIdentity.metadataAgentIdentity.create_key_based()AgentIdentity.sign_message()AgentIdentity.verify_signature()AgentIdentity.to_dict()AgentIdentity.from_dict()
AgentMetadataAgentMetadata.agent_idAgentMetadata.agent_typeAgentMetadata.identityAgentMetadata.organization_idAgentMetadata.capabilitiesAgentMetadata.interaction_modesAgentMetadata.payment_addressAgentMetadata.metadataAgentMetadata.agent_idAgentMetadata.agent_typeAgentMetadata.identityAgentMetadata.organization_idAgentMetadata.capabilitiesAgentMetadata.interaction_modesAgentMetadata.payment_addressAgentMetadata.metadata
SkillAgentProfileAgentProfile.agent_idAgentProfile.agent_typeAgentProfile.nameAgentProfile.summaryAgentProfile.descriptionAgentProfile.versionAgentProfile.documentation_urlAgentProfile.organizationAgentProfile.developerAgentProfile.urlAgentProfile.auth_schemesAgentProfile.default_input_modesAgentProfile.default_output_modesAgentProfile.capabilitiesAgentProfile.skillsAgentProfile.examplesAgentProfile.tagsAgentProfile.payment_addressAgentProfile.custom_metadataAgentProfile.reputation_scoreAgentProfile.agent_idAgentProfile.agent_typeAgentProfile.nameAgentProfile.summaryAgentProfile.descriptionAgentProfile.versionAgentProfile.documentation_urlAgentProfile.organizationAgentProfile.developerAgentProfile.urlAgentProfile.auth_schemesAgentProfile.default_input_modesAgentProfile.default_output_modesAgentProfile.capabilitiesAgentProfile.skillsAgentProfile.examplesAgentProfile.tagsAgentProfile.payment_addressAgentProfile.custom_metadataAgentProfile.reputation_scoreAgentProfile.model_config
MessageTypeMessageType.TEXTMessageType.COMMANDMessageType.RESPONSEMessageType.ERRORMessageType.VERIFICATIONMessageType.CAPABILITYMessageType.PROTOCOLMessageType.STOPMessageType.SYSTEMMessageType.COOLDOWNMessageType.IGNOREMessageType.REQUEST_COLLABORATIONMessageType.COLLABORATION_RESPONSEMessageType.COLLABORATION_ERROR
NetworkMode