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_PREVIEW = 'gemini-2.5-pro-preview-03-25'¶
- GEMINI2_5_PRO_EXP = 'gemini-2.5-pro-exp-03-25'¶
- GEMINI2_5_FLASH_PREVIEW = 'gemini-2.5-flash-preview-04-17'¶
- 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'¶
- GEMINI1_5_FLASH = 'gemini-1.5-flash'¶
- GEMINI1_5_PRO = 'gemini-1.5-pro'¶
- 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.
- 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)¶
Find agents by capability description using semantic search.
- Parameters:
- 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_id)¶
Find agents by organization.
- Parameters:
organization_id (
str) – ID 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- 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.
- 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
- async verify_agent(agent_id)¶
Verify an agent’s identity.
Subpackages¶
- agentconnect.core.registry package
AgentRegistryAgentRegistry.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.verify_agent()AgentRegistry.verify_owner()
AgentRegistrationAgentRegistration.agent_idAgentRegistration.organization_idAgentRegistration.agent_typeAgentRegistration.interaction_modesAgentRegistration.capabilitiesAgentRegistration.identityAgentRegistration.owner_idAgentRegistration.payment_addressAgentRegistration.metadataAgentRegistration.owner_idAgentRegistration.payment_addressAgentRegistration.agent_idAgentRegistration.organization_idAgentRegistration.agent_typeAgentRegistration.interaction_modesAgentRegistration.capabilitiesAgentRegistration.identityAgentRegistration.metadata
CapabilityDiscoveryServiceCapabilityDiscoveryService.clear_agent_embeddings_cache()CapabilityDiscoveryService.find_by_capability_name()CapabilityDiscoveryService.find_by_capability_semantic()CapabilityDiscoveryService.initialize_embeddings_model()CapabilityDiscoveryService.load_vector_store()CapabilityDiscoveryService.precompute_all_capability_embeddings()CapabilityDiscoveryService.save_vector_store()CapabilityDiscoveryService.update_capability_embeddings_cache()
- Submodules
Submodules¶
- agentconnect.core.agent module
BaseAgentBaseAgent.agent_idBaseAgent.identityBaseAgent.metadataBaseAgent.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.payment_constants module
- 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_PRO_PREVIEWModelName.GEMINI2_5_PRO_EXPModelName.GEMINI2_5_FLASH_PREVIEWModelName.GEMINI2_FLASHModelName.GEMINI2_FLASH_LITEModelName.GEMINI2_PRO_EXPModelName.GEMINI2_FLASH_THINKING_EXPModelName.GEMINI1_5_FLASHModelName.GEMINI1_5_PROModelName.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
MessageTypeMessageType.TEXTMessageType.COMMANDMessageType.RESPONSEMessageType.ERRORMessageType.VERIFICATIONMessageType.CAPABILITYMessageType.PROTOCOLMessageType.STOPMessageType.SYSTEMMessageType.COOLDOWNMessageType.IGNOREMessageType.REQUEST_COLLABORATIONMessageType.COLLABORATION_RESPONSEMessageType.COLLABORATION_ERROR
NetworkMode