Example Task
Suppose we want the agents to complete the following sequence of tasks:Step 1. Define Agents
A Group Chat for Inner Monologue
Below, we construct a group chat manager which manages aninner_assistant agent and an inner_code_interpreter agent. Later we
will use this group chat inside another agent.
Inner- and Outer-Level Individual Agents
Now we will construct a number of individual agents that will assume role of outer and inner agents.Step 2: Orchestrate Nested Chats to Solve Tasks
Outer Level
In the following code block, at the outer level, we have communication between:user-assistant_1for solving the first task, i.e.,tasks[0].user-assistant_2for solving the second task, i.e.,tasks[1].
Inner Level (Nested Chats)
Since the first task is quite complicated, we created a sequence of nested chats as the inner monologue of Assistant_1.-
assistant_1-manager: This chat intends to delegate the task received by Assistant_1 to the Manager to solve. -
assistant_1-writer: This chat takes the output from Nested Chat 1, i.e., Assistant_1 vs. Manager, and lets the Writer polish the content to make an engaging and nicely formatted blog post, which is realized through the writing_message function. -
assistant_1-reviewer: This chat takes the output from Nested Chat 2 and intends to let the Reviewer agent review the content from Nested Chat 2. -
assistant_1-writer: This chat takes the output from previous nested chats and intends to let the Writer agent finalize a blog post.
register_nested_chats function, which allows one to register one or a
sequence of chats to a particular agent (in this example, the
assistant_1 agent).
Information about the sequence of chats can be specified in the
chat_queue argument of the register_nested_chats function. The
following fields are especially useful: - recipient (required)
specifies the nested agent; - message specifies what message to send
to the nested recipient agent. In a sequence of nested chats, if the
message field is not specified, we will use the last message the
registering agent received as the initial message in the first chat and
will skip any subsequent chat in the queue that does not have the
message field. You can either provide a string or define a callable
that returns a string. - summary_method decides what to get out of the
nested chat. You can either select from existing options including
"last_msg" and "reflection_with_llm", or or define your own way on
what to get from the nested chat with a Callable. - max_turns
determines how many turns of conversation to have between the concerned
agent pairs.