Complete the code to define a basic message format for agent communication.
message = {"sender": "AgentA", "receiver": "AgentB", "content": [1]The content of a message should be a string representing the information sent between agents.
Complete the code to send a message using a standard send function.
def send_message(agent, message): agent.[1](message)
The send_message function should call the agent's send method to transmit the message.
Fix the error in the message parsing code to extract the sender correctly.
def parse_message(msg): sender = msg[[1]] return sender
Messages are dictionaries, so the sender is accessed by the key 'sender', not by index.
Fill both blanks to create a filter that selects messages sent by 'AgentX' and containing 'urgent'.
filtered = [msg for msg in messages if msg[[1]] == 'AgentX' and 'urgent' [2] msg["content"]]
We check if the sender key equals 'AgentX' and if the string 'urgent' is in the content.
Fill all three blanks to build a dictionary comprehension mapping agent names to their last received message content.
last_messages = {agent: messages[-1][[1]] for agent, messages in [2].items() if messages and messages[-1][[3]] == agent}The comprehension uses 'inbox' as the dictionary of messages per agent, maps agent to last message content, and checks if the last message's receiver matches the agent.
