Package com.tnsai.protocols.handlers
Class DebateProtocolHandler
java.lang.Object
com.tnsai.protocols.handlers.AbstractProtocolHandler
com.tnsai.protocols.handlers.DebateProtocolHandler
- All Implemented Interfaces:
ProtocolHandler
Handler for multi-agent debate and consensus building protocol.
Supports:
- Round-based discussions with configurable max rounds
- Opinion/position submission with confidence scores
- Voting and counter-arguments
- Multiple consensus strategies (majority, supermajority, unanimous, weighted)
- Automatic deadlock detection
Thread-safe implementation for concurrent multi-agent debates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResult of consensus check.static classRepresents an active debate session.static enumDebate status.static classAgent position in a debate.static classSnapshot of a completed round.Nested classes/interfaces inherited from interface com.tnsai.protocols.handlers.ProtocolHandler
ProtocolHandler.HandlerCallback, ProtocolHandler.HandlerException -
Constructor Summary
ConstructorsConstructorDescriptionDebateProtocolHandler(Transport transport, int maxRounds, double consensusThreshold, com.tnsai.protocols.annotations.Debate.ConsensusStrategy strategy, long roundTimeoutMs) -
Method Summary
Modifier and TypeMethodDescriptionGets all active debates.Gets an active debate session.com.tnsai.protocols.models.Messagesend(com.tnsai.protocols.models.Message message) Sends a message using this protocol.voidsendAsync(com.tnsai.protocols.models.Message message, ProtocolHandler.HandlerCallback callback) Sends a message asynchronously.startDebate(String topic, com.tnsai.protocols.models.AgentEndpoint initiator, List<String> participants) Starts a new debate.voidsubmitCounterArgument(String debateId, com.tnsai.protocols.models.AgentEndpoint sender, String targetAgent, String counterArgument, String alternative) Submits a counter-argument.voidsubmitPosition(String debateId, com.tnsai.protocols.models.AgentEndpoint sender, String stance, int confidence, String reasoning) Submits a position/opinion for the current round.voidvote(String debateId, com.tnsai.protocols.models.AgentEndpoint voter, String targetStance, boolean support) Submits a vote on a position.Methods inherited from class com.tnsai.protocols.handlers.AbstractProtocolHandler
getTransport, isRunning, start, stop
-
Constructor Details
-
DebateProtocolHandler
public DebateProtocolHandler(Transport transport, int maxRounds, double consensusThreshold, com.tnsai.protocols.annotations.Debate.ConsensusStrategy strategy, long roundTimeoutMs)
-
-
Method Details
-
startDebate
public DebateProtocolHandler.DebateSession startDebate(String topic, com.tnsai.protocols.models.AgentEndpoint initiator, List<String> participants) throws ProtocolHandler.HandlerException Starts a new debate.- Parameters:
topic- Debate topicinitiator- Agent starting the debateparticipants- List of participating agent IDs- Returns:
- DebateSession for tracking
- Throws:
ProtocolHandler.HandlerException
-
submitPosition
public void submitPosition(String debateId, com.tnsai.protocols.models.AgentEndpoint sender, String stance, int confidence, String reasoning) throws ProtocolHandler.HandlerException Submits a position/opinion for the current round.- Parameters:
debateId- Debate session IDsender- Agent submitting positionstance- The position being takenconfidence- Confidence level (1-10)reasoning- Explanation for the position- Throws:
ProtocolHandler.HandlerException
-
vote
public void vote(String debateId, com.tnsai.protocols.models.AgentEndpoint voter, String targetStance, boolean support) throws ProtocolHandler.HandlerException Submits a vote on a position.- Parameters:
debateId- Debate session IDvoter- Voting agenttargetStance- Stance being voted onsupport- True for support, false for oppose- Throws:
ProtocolHandler.HandlerException
-
submitCounterArgument
public void submitCounterArgument(String debateId, com.tnsai.protocols.models.AgentEndpoint sender, String targetAgent, String counterArgument, String alternative) throws ProtocolHandler.HandlerException Submits a counter-argument.- Parameters:
debateId- Debate session IDsender- Agent making counter-argumenttargetAgent- Agent being counteredcounterArgument- The counter-argument textalternative- Optional alternative proposal- Throws:
ProtocolHandler.HandlerException
-
getDebate
Gets an active debate session. -
getActiveDebates
Gets all active debates. -
send
public com.tnsai.protocols.models.Message send(com.tnsai.protocols.models.Message message) throws ProtocolHandler.HandlerException Description copied from interface:ProtocolHandlerSends a message using this protocol.- Parameters:
message- Message to send- Returns:
- Response message (null for async protocols)
- Throws:
ProtocolHandler.HandlerException- if send fails
-
sendAsync
public void sendAsync(com.tnsai.protocols.models.Message message, ProtocolHandler.HandlerCallback callback) Description copied from interface:ProtocolHandlerSends a message asynchronously.- Parameters:
message- Message to sendcallback- Callback for response
-