

Introduction
In the traditional ML pipeline, we train a model by updating its weights according to the loss on the training set, while in the era of LLM agents, how should we train an agent? Here, we take an initial step towards the agent training. Inspired by the function calling capabilities provided by OpenAI, we draw an analogy between model weights and agent functions/skills, and update an agent’s functions/skills based on its historical performance on a training set. Specifically, we propose to use the function calling capabilities to formulate the actions that optimize the agents’ functions as a set of function calls, to support iteratively adding, revising, and removing existing functions. We also include two strategies, roll-back, and early-stop, to streamline the training process to overcome the performance-decreasing problem when training. As an agentic way of training an agent, our approach helps enhance the agents’ abilities without requiring access to the LLM’s weights.AgentOptimizer
AgentOptimizer is a class designed to optimize the agents by improving their function calls. It contains three main methods:record_one_conversation
:
step()
:
step()
is the core method of AgentOptimizer.
At each optimization iteration, it will return two fields register_for_llm and register_for_executor, which are subsequently utilized to update the assistant and UserProxy agents, respectively.
reset_optimizer
:
Pseudocode for the optimization process
The optimization process is as follows:The implementation technology behind the AgentOptimizer
To obtain stable and structured function signatures and code implementations from AgentOptimizer, we leverage the function calling capabilities provided by OpenAI to formulate the actions that manipulate the functions as a set of function calls. Specifically, we introduce three function calls to manipulate the current functions at each step:add_function
, remove_function
, and revise_function
.
These calls add, remove, and revise functions in the existing function list, respectively.
This practice could fully leverage the function calling capabilities of GPT-4 and output structured functions with more stable signatures and code implementation.
Below is the JSON schema of these function calls:
add_function
: Add one new function that may be used in the future tasks.
revise_function
: Revise one existing function (code implementation, function signature) in the current function list according to the conversation history and performance.
remove_function
: Remove one existing function in the current function list. It is used to remove the functions that are not useful (redundant) in the future tasks.
Limitation & Future work
- Currently, it only supports optimizing the one typical user_proxy and assistant agents pair. We will make this feature more general to support other agent types in future work.
- The current implementation of AgentOptimizer is effective solely on the OpenAI GPT-4 model. Extending this feature/concept to other LLMs is the next step.