Step-by-step agent state management¶
In this section, you will see how the agent state is managed in our framework.
The big picture¶
The following diagram gives you a high-level understanding of how the agent state management works for a generic negotiation.
Let’s see step by step what happens:
Agent_1sends aCFPtoAgent_2, meaning that she wants to start a negotiation. The CFP contains a reference to the goods whichAgent_1is interested in and whetherAgent_1is a buyer or seller of these goods.Assuming
Agent_2does not decline the CFP,Agent_2callsget_proposals()to generate a list of proposal for answering toAgent_1. When generating the proposalsAgent_2applies all locked transactions - we discuss below when a transaction becomes locked - to the current agent state to generate a “forward looking agent state” (i.e. the state the agent will be in when all locked transactions have been settled by theController). This ensuresAgent_2takes into account all the transactions she has committed to.Agent_2callsstore_proposals()to store the proposals aspending_proposals.Agent_2replies with aProposemessage which includes the proposals as an answer to theCFP(note, currently the list of proposals includes exactly one proposal).Agent_1translates the proposal into a transaction and callsis_profitable_transaction()to identify whether the transaction is profitable.Assuming the proposal is profitable,
Agent_1callsadd_locked_tx()to add the transaction to the list of locked transactions.Agent_1callsadd_pending_initial_acceptance()to add the transaction to the list of pending initial acceptances. This helps the agent identify whether an incomingAcceptfromAgent_2is a matching accept or an initial accept.Agent_1sends anAcceptmessage toAgent_2, meaning that she accepts the proposal.Agent_2callspop_pending_proposal()to recover the proposal - in the form of a transaction - made toAgent_1and referenced in the acceptance message.Agent_2callsis_profitable_transaction()to identify whether the transaction is profitable. This proposal was created byAgent_2, however in the meanwhileAgent_2might have a different agent state which could render this proposal no longer profitable.Assuming the proposal is still profitable,
Agent_2callsadd_locked_tx()to add the transaction to the list of locked transactions.Agent_2sends anAcceptmessage toAgent_1, meaning that she “match-accepts” the proposal.Agent_2sends a Transaction request to theController.Agent_1callspop_pending_initial_acceptance()toAgent_1sends a Transaction request to theController(analogous to step 13).The
ControllernotifiesAgent_1that the transaction has been confirmed.Agent_1callspop_locked_tx()to remove the transaction from the locked transaction list.Agent_1callsagent_state.update()to update its state.The
ControllernotifiesAgent_2that the transaction has been confirmed.Agent_2callspop_locked_tx()to remove the transaction from the locked transaction list (analogous to step 17).Agent_2callsagent_state.update()to update its state (analogous to step 18).