Package dev.agenor.core.dialogue
Interface CommitmentTracker
- All Known Implementing Classes:
DefaultCommitmentTracker
public interface CommitmentTracker
Tracks and manages commitments across conversations.
- Since:
- 0.5.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidCancels a commitment (by debtor).Checks for commitments that have exceeded their deadline.default intRemoves commitments that have reached a terminal state and are older than the given duration.createFromMessage(DialogueMessage message) Creates a new commitment from a dialogue message.Retrieves a commitment by ID.getActiveAsPerformer(String agentId) Gets all active commitments where the agent is the performer.getActiveAsRequester(String agentId) Gets all active commitments where the agent is the requester.getByMessageId(String messageId) Retrieves the ID of the commitment created by a given message.voidReleases a commitment (by creditor).voidupdateFromResponse(String commitmentId, DialogueMessage response) Updates a commitment based on a response message.
-
Method Details
-
createFromMessage
Creates a new commitment from a dialogue message.- Parameters:
message- the message that creates the commitment (e.g., REQUEST, AGREE)- Returns:
- the created commitment
-
updateFromResponse
Updates a commitment based on a response message.- Parameters:
commitmentId- the commitment to updateresponse- the response message (e.g., INFORM, FAILURE)
-
get
Retrieves a commitment by ID.- Parameters:
commitmentId- the commitment ID- Returns:
- the commitment if found
-
getByMessageId
Retrieves the ID of the commitment created by a given message.Used to correlate an incoming reply with the commitment its original message created, so that the commitment can be advanced by
updateFromResponse(String, DialogueMessage).- Parameters:
messageId- the ID of the message that created the commitment; may be null- Returns:
- the commitment ID if that message created one
- Since:
- 0.26.0
-
getActiveAsPerformer
Gets all active commitments where the agent is the performer.- Parameters:
agentId- the agent ID- Returns:
- list of active commitments to fulfill
-
getActiveAsRequester
Gets all active commitments where the agent is the requester.- Parameters:
agentId- the agent ID- Returns:
- list of active commitments awaiting fulfillment
-
checkViolations
List<Commitment> checkViolations()Checks for commitments that have exceeded their deadline.- Returns:
- list of violated commitments
-
cancel
Cancels a commitment (by debtor).- Parameters:
commitmentId- the commitment to cancelreason- optional reason for cancellation
-
release
Releases a commitment (by creditor).- Parameters:
commitmentId- the commitment to release
-
cleanup
Removes commitments that have reached a terminal state and are older than the given duration.Commitments outlive the message exchange that created them so that they remain observable after the fact; without a periodic sweep they accumulate for the whole lifetime of the agent. Implementations backed by a store with its own expiry may leave this as the default no-op.
- Parameters:
olderThan- retention window measured from the commitment's creation time;Duration.ZEROremoves every terminated commitment- Returns:
- the number of commitments removed
- Since:
- 0.26.0
-