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_1
sends aCFP
toAgent_2
, meaning that she wants to start a negotiation. The CFP contains a reference to the goods whichAgent_1
is interested in and whetherAgent_1
is a buyer or seller of these goods.Assuming
Agent_2
does not decline the CFP,Agent_2
callsget_proposals()
to generate a list of proposal for answering toAgent_1
. When generating the proposalsAgent_2
applies 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_2
takes into account all the transactions she has committed to.Agent_2
callsstore_proposals()
to store the proposals aspending_proposals
.Agent_2
replies with aPropose
message which includes the proposals as an answer to theCFP
(note, currently the list of proposals includes exactly one proposal).Agent_1
translates the proposal into a transaction and callsis_profitable_transaction()
to identify whether the transaction is profitable.Assuming the proposal is profitable,
Agent_1
callsadd_locked_tx()
to add the transaction to the list of locked transactions.Agent_1
callsadd_pending_initial_acceptance()
to add the transaction to the list of pending initial acceptances. This helps the agent identify whether an incomingAccept
fromAgent_2
is a matching accept or an initial accept.Agent_1
sends anAccept
message toAgent_2
, meaning that she accepts the proposal.Agent_2
callspop_pending_proposal()
to recover the proposal - in the form of a transaction - made toAgent_1
and referenced in the acceptance message.Agent_2
callsis_profitable_transaction()
to identify whether the transaction is profitable. This proposal was created byAgent_2
, however in the meanwhileAgent_2
might have a different agent state which could render this proposal no longer profitable.Assuming the proposal is still profitable,
Agent_2
callsadd_locked_tx()
to add the transaction to the list of locked transactions.Agent_2
sends anAccept
message toAgent_1
, meaning that she “match-accepts” the proposal.Agent_2
sends a Transaction request to theController
.Agent_1
callspop_pending_initial_acceptance()
toAgent_1
sends a Transaction request to theController
(analogous to step 13).The
Controller
notifiesAgent_1
that the transaction has been confirmed.Agent_1
callspop_locked_tx()
to remove the transaction from the locked transaction list.Agent_1
callsagent_state.update()
to update its state.The
Controller
notifiesAgent_2
that the transaction has been confirmed.Agent_2
callspop_locked_tx()
to remove the transaction from the locked transaction list (analogous to step 17).Agent_2
callsagent_state.update()
to update its state (analogous to step 18).