💡Starter‑Kit Update – OpenAI-friendly function call interface

Starter‑Kit Update – OpenAI-friendly function call interface

We have made a small change to the starter kit to make it more compatible with the OpenAI function calling format. This also makes it easier for you to participate in the API track — where you only need to call the OpenAI API to compete, and no costly fine-tuning is needed.

What Changed?

File Purpose
function_calls/tool_functions_XXX.py, function_calls/action_functions_XXX.py We revised the implementation of the function_registry within each function file. The values of the function_registry are now fully compatible with the OpenAI function calling format.
agents/new_openai_agent.py A new (and much simpler) implementation of the OpenAI agent that can be submitted to the API track.

We renamed the directory function_call_langchain to function_calls.

Please note that agents/vanilla_llama_agent.py does not need changes to work, although we did make it structurally cleaner.

Quick Start

The following code snippet is taken from agents/new_openai_agent.py, where we can directly obtain OpenAI-compatible functions from the registry, without any pre-processing.

   def _prepare_openai_functions(self, tool_registry, action_registry):
       """
       Prepare the list of functions as inputs to the OpenAI API.
       The values of `tool_registry` and `action_registry` have already been converted to the OpenAI function calling format.


       Args:
           tool_registry: A dict mapping tool names to tool functions (OpenAI function calling format).
           action_registry: A dict mapping action names to action function (OpenAI function calling format).
           Implementations can be found in the directory `function_calls`.


       Returns:
           openai_functions: List[Dict], a list of functions in the OpenAI function calling format.
       """
       openai_tool_functions = []
       for tool_name, tool_function in tool_registry['function_registry'].items():
           tool_function['type'] = 'function'
           # With my openai=1.77.0 and langchain=0.3.25 version, this should be manually added.
           # Please note that this may not be necessary for all OpenAI and langchain versions.
           # Please test it before submission.
           openai_tool_functions.append(tool_function)


       openai_action_functions = []
       for action_name, action_function in action_registry['function_registry'].items():
           action_function['type'] = 'function'
           openai_action_functions.append(action_function)
       openai_functions = openai_tool_functions + openai_action_functions
       return openai_functions

How the Change Works.

The change is made possible by the langchain package, as well as the helper function convert_to_openai_function. Specifically,

  • Each tool or action function is defined as a langchain.tool.
  • During the construction of the function_registry in each function file, we apply convert_to_openai_function.

As an example, the following code snippet is taken from function_calls/action_functions_0001.py.

@tool
def equip(item_name: str) -> None:
   """
   Equip the specified weapon (e.g. Avis Wind, Short Sword, etc.).
  
   Parameters:
   ----------
   item_name: str
       Specified weapon name (e.g. Avis Wind, Short Sword, etc.). Uses the weapon name mentioned in the conversation.


   Returns:
   -------
   None
   """


   pass


all_functions = [sell, equip]
action_functions_0001 = {'function_registry': {
   f.name: convert_to_openai_function(f, strict=True) for f in all_functions
}}

Guidelines and Caveats

  • If you want to find out more about the functions and how they are transformed into the OpenAI format, please checkout the function_calls directory, and the documents of langchain. You can also find more details on the OpenAI function calling format here.
  • Please do not change anything in the function_calls directory. During evaluation, we will overwrite the directory in the starter kit with the one used by the evaluator, so all local changes will be lost.

Action Required

  • git pull (or re‑clone) the starter‑kit.
  • Revise your agent implementation accordingly.
  • Run your usual tests to confirm everything works as expected.

If you hit any issues, open a thread in the forum and tag the organisers—happy hacking!