code: def test_mode_customized():
      try:
          assistant = CompressibleAgent(
              name="assistant",
              llm_config={
                  "timeout": 600,
                  "cache_seed": 43,
                  "config_list": config_list,
                  "model": "gpt-3.5-turbo",
              },
              compress_config={
                  "mode": "CUSTOMIZED",
              },
          )
      except ValueError:
          print("ValueError raised as expected.")
  
      def constrain_num_messages(messages):
          """Constrain the number of messages to 3.
  
          This is an example of a customized compression function.
  
          Returns:
              bool: whether the compression is successful.
              list: the compressed messages.
          """
          if len(messages) <= 3:
              # do nothing
              return False, None
  
          # save the first and last two messages
          return True, messages[:1] + messages[-2:]
  
      # create a CompressibleAgent instance named "assistant"
      assistant = CompressibleAgent(
          name="assistant",
          llm_config={
              "timeout": 600,
              "cache_seed": 43,
              "config_list": config_list,
              "model": "gpt-3.5-turbo",
          },
          compress_config={
              "mode": "CUSTOMIZED",
              "compress_function": constrain_num_messages,  # this is required for customized compression
              "trigger_count": 1000,
          },
      )
  
      # create a UserProxyAgent instance named "user_proxy"
      user_proxy = autogen.UserProxyAgent(
          name="user_proxy",
          human_input_mode="NEVER",
          max_consecutive_auto_reply=5,
          is_termination_msg=lambda x: x.get("content", "")
          .rstrip()
          .endswith("TERMINATE")
          or x.get("content", "").rstrip().endswith("TERMINATE."),
          code_execution_config={"work_dir": "web"},
          system_message="""Reply TERMINATE if the task has been solved at full satisfaction.
      Otherwise, reply CONTINUE, or the reason why the task is not solved yet.""",
      )
  
      user_proxy.initiate_chat(
          assistant,
          message="""Show me the YTD gain of 10 largest technology companies as of today.""",
      )
  
file_path: autogen/test/agentchat/contrib/test_compressible_agent.py
imports: import pytest
  import sys
  import autogen
  import os
  from autogen.agentchat.contrib.compressible_agent import CompressibleAgent
  from conftest import skip_openai
  from test_assistant_agent import OAI_CONFIG_LIST, KEY_LOC
label_desc: Use image node_id 2 for calling a global function with example usage: test_mode_customized() and returns: True,  unknown, False,  None