Package com.tnsai.protocols
package com.tnsai.protocols
Agent communication protocols for multi-agent coordination.
This package provides various communication patterns for agents to exchange messages and coordinate actions. Protocols define how agents discover each other and exchange information.
Communication Patterns
┌─────────────────────────────────────────────────────────────┐ │ Communication Patterns │ ├─────────────────────────────────────────────────────────────┤ │ │ │ Direct (Point-to-Point) Broadcast (One-to-Many) │ │ ───────────────────── ──────────────────────── │ │ Agent A ──► Agent B Agent A ──┬──► Agent B │ │ ├──► Agent C │ │ └──► Agent D │ │ │ │ PubSub (Topic-Based) Request-Reply │ │ ───────────────────── ───────────────── │ │ Publishers ──► Topic Agent A ──► Agent B │ │ │ ◄──────── │ │ Subscribers ◄───┘ (bidirectional) │ │ │ └─────────────────────────────────────────────────────────────┘
Available Protocols
| Protocol | Pattern | Use Case |
|---|---|---|
| DirectProtocol | Point-to-point | Targeted agent communication |
| BroadcastProtocol | One-to-many | Announcements, notifications |
| PubSubProtocol | Topic-based | Event-driven architectures |
| RequestReplyProtocol | Bidirectional | Queries, RPC-style calls |
Usage Example
// Protocol Manager coordinates all protocols
ProtocolManager manager = new ProtocolManager();
// Register agents
manager.register(researchAgent);
manager.register(writerAgent);
// Direct communication
manager.send("writer-agent", "Please write about: " + topic);
// Broadcast to all
manager.broadcast("System maintenance in 5 minutes");
// PubSub pattern
manager.subscribe("news-topic", newsAgent);
manager.publish("news-topic", "Breaking news: ...");
// Request-Reply
String response = manager.request("research-agent", "Find papers on AI");
Protocol Selection Guide
- Direct: When you know the specific recipient
- Broadcast: For system-wide announcements
- PubSub: For decoupled, event-driven systems
- Request-Reply: When you need a response
Transport Layer
Protocols are transport-agnostic. See tnsai-distributed-redis
module for Redis-based distributed transport.
- Since:
- 0.0.2
- See Also:
-
ClassesClassDescriptionDefault SPI implementation of
ProtocolManagerHandle.Factory.Protocol Manager - Orchestrates all communication paradigms for an agent.