Explore common use cases for custom communication flows in Agency Swarm.
SendMessageBase
tool and how to implement them, so you can learn how to create your own SendMessage tools and use them in your own applications.
message
parameter. This can help you better customize how the agents communicate with each other and what information they relay.
Let’s say that instead of sending messages, I want my agents to send tasks to each other. In this case, I can change the docstring and the message
parameter to a task
parameter to better fit the nature of my application.
chain_of_thought
parameter.
recipient
parameter, which is defined in the SendMessageBase
class. Since I don’t want to change any other parameters or descriptions, I can inherit the default SendMessage
class and only add this new validation logic.
llm_validator
will throw an error if the message is not related to customer support. The caller agent will then have to fix the recipient or the message and send it again! This is extremely useful when you have a lot of agents.
SendMessage
, the agents might not relay all the necessary details to the recipient agent, especially when the previous conversation is too long. In this case, you can summarize the previous conversation with GPT and add it to the context, instead of the additional instructions. I will extend the SendMessageQuick
class, which already contains the message
parameter, as I don’t need chain of thought or files in this case.
run
method. It does not have to be a summary; you can also use it to add any other information to the context. For example, you can even query a vector database or use an external API.
_get_completion()
, you can call your own API and let the agents communicate with each other over the internet.
agency_swarm/tools/send_message
folder and open a PR!SendMessage
tool, simply pass it into the send_message_tool_class
parameter when initializing the Agency
class:
SendMessageAPI
class for communication!