Orchestrating Agents: Routines and Handoffs | OpenAI Cookbook #930
Labels
AI-Agents
Autonomous AI agents using LLMs
AI-Chatbots
Topics related to advanced chatbot platforms integrating multiple AI models
Automation
Automate the things
Code-Interpreter
OpenAI Code-Interpreter
llm
Large Language Models
llm-applications
Topics related to practical applications of Large Language Models in various fields
llm-function-calling
Function Calling with Large Language Models
openai
OpenAI APIs, LLMs, Recipes and Evals
Software2.0
Software development driven by AI and neural networks.
Orchestrating Agents: Routines and Handoffs | OpenAI Cookbook
Routines
A routine is defined as a list of instructions in natural language (represented by a system prompt), along with the tools necessary to complete them. Here's an example of a customer service routine:
The power of routines lies in their simplicity and robustness. LLMs can handle these conditional instructions quite robustly for small and medium-sized routines, with the added benefit of "soft" adherence - the LLM can naturally steer the conversation without getting stuck in dead-ends.
Handoffs
A handoff is defined as an agent (or routine) handing off an active conversation to another agent, much like when you get transferred to someone else on a phone call. The agents have complete knowledge of the prior conversation.
To implement handoffs, we define an
Agent
class and modify therun_full_turn
function to handle agent transfers:Agents can express the intent to make a handoff by returning an
Agent
object from their tool functions. Therun_full_turn
function then updates the current agent accordingly.Example
Here's an example with multiple agents:
The agents can then be used in a loop, allowing the user to interact with the different agents as needed:
Swarm
As a proof of concept, these ideas have been packaged into a sample library called Swarm. It is meant as an example only and should not be directly used in production. However, feel free to take the ideas and code to build your own.
Suggested labels
None
The text was updated successfully, but these errors were encountered: