praval.core.reef๏
Reef Communication System for Praval Framework.
Like coral reefs facilitate communication between polyps through chemical and biological signals, this system enables knowledge-first communication between agents through structured JSON message queues.
Components: - Spores: JSON messages containing knowledge, data, or requests - ReefChannel: Named message channels within the reef - Reef: The message queue network connecting all agents
Functions
|
Get the global reef instance. |
Classes
|
The Reef manages all communication channels and facilitates agent communication. |
|
A message channel within the reef. |
|
A spore is a knowledge-carrying message that flows through the reef. |
|
Types of spores that can flow through the reef. |
- class praval.core.reef.SporeType(*values)[source]๏
Bases:
EnumTypes of spores that can flow through the reef.
- KNOWLEDGE = 'knowledge'๏
- REQUEST = 'request'๏
- RESPONSE = 'response'๏
- BROADCAST = 'broadcast'๏
- NOTIFICATION = 'notification'๏
- class praval.core.reef.Spore(id, spore_type, from_agent, to_agent, knowledge, created_at, expires_at=None, priority=5, reply_to=None, metadata=None, knowledge_references=None, data_references=None)[source]๏
Bases:
objectA spore is a knowledge-carrying message that flows through the reef.
Like biological spores, each carries: - Genetic material (knowledge/data) - Identification markers (metadata) - Survival instructions (processing hints)
Spores can carry either direct knowledge or lightweight references to knowledge stored in vector memory, following the principle that โlight spores travel far.โ
- Parameters:
- add_knowledge_reference(reference_id)[source]๏
Add a reference to stored knowledge
- Parameters:
reference_id (str)
- add_data_reference(reference_uri)[source]๏
Add a reference to storage system data
- Parameters:
reference_uri (str)
- __init__(id, spore_type, from_agent, to_agent, knowledge, created_at, expires_at=None, priority=5, reply_to=None, metadata=None, knowledge_references=None, data_references=None)๏
- Parameters:
- Return type:
None
- class praval.core.reef.ReefChannel(name, max_capacity=1000, max_workers=4)[source]๏
Bases:
objectA message channel within the reef.
Like channels in a coral reef, they: - Have directional flow patterns - Can carry multiple spores simultaneously - Have capacity limits (to prevent overwhelming) - Can experience turbulence (message loss/delays)
- class praval.core.reef.Reef(default_max_workers=4)[source]๏
Bases:
objectThe Reef manages all communication channels and facilitates agent communication.
Like a coral reef ecosystem, it: - Maintains multiple communication channels - Enables knowledge flow between polyps (agents) - Supports both direct and broadcast communication - Provides network health monitoring
- Parameters:
default_max_workers (int)
- create_channel(name, max_capacity=1000, max_workers=None)[source]๏
Create a new reef channel.
- Return type:
- Parameters:
- send(from_agent, to_agent, knowledge, spore_type=SporeType.KNOWLEDGE, channel=None, priority=5, expires_in_seconds=None, reply_to=None, knowledge_references=None, auto_reference_large_knowledge=True)[source]๏
Send a spore through the reef.
- broadcast(from_agent, knowledge, channel=None)[source]๏
Broadcast knowledge to all agents in the reef.
- system_broadcast(knowledge, channel=None)[source]๏
Broadcast system-level messages to all agents in a channel.
- request(from_agent, to_agent, request, channel=None, expires_in_seconds=300)[source]๏
Send a knowledge request to another agent.
- reply(from_agent, to_agent, response, reply_to_spore_id, channel=None)[source]๏
Reply to a knowledge request.
- subscribe(agent_name, handler, channel=None)[source]๏
Subscribe an agent to receive spores from a channel.
- create_knowledge_reference_spore(from_agent, to_agent, knowledge_summary, knowledge_references, spore_type=SporeType.KNOWLEDGE, channel=None)[source]๏
Create a lightweight spore with knowledge references
This follows the reef principle: โlight spores travel farโ