# Create custom agents with AutoGen The [AutoGen](https://microsoft.github.io/autogen/) AgentChat framework allows you to build custom agents for single or multi-agent applications. Autogen agents can process multi-model input, generate and execute code, and stream output. ## Install AutoGen pip install autogen-agentchat~=0.2 Copy to clipboard ## Create agents to code a function In this example, there are two agents to code a function that sorts a Python list: - The first agent codes the function. - The second agent runs the code. import httpx from autogen import ConversableAgent, UserProxyAgent class HttpClient(httpx.Client): def __deepcopy__(self, memo): return self # Enter base_url and api_key config_list = [ { "model": "Llama-3.1-8B", "base_url": "", "api_key": "", "max_tokens": 256, "temperature": 0.5, "http_client": HttpClient(verify=False), } ] assistant = ConversableAgent("assistant", llm_config={"config_list": config_list}) user_proxy = UserProxyAgent( "user_proxy", code_execution_config={ "work_dir": "coding", "use_docker": False, }, ) code_writer_agent_system_message = assistant.system_message print(" system message ".center(100, "=")) print(code_writer_agent_system_message) print( " code for prompt: Write python code to perform a quicksort over a python list ".center( 100, "=" ) ) user_proxy.initiate_chat( assistant, message="Write python code to perform a quicksort over a python list", verify=False, ) print("=" * 100) Copy to clipboard The output is similar to the following: Here is an example of a Python implementation of the quicksort algorithm: ``` def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[0] less = [x for x in arr[1:] if x <= pivot] greater = [x for x in arr[1:] if x > pivot] return quicksort(less) + [pivot] + quicksort(greater) ``` This implementation uses the "Lomuto" partition scheme, which is a variation of the standard "Hoare" partition scheme that is slightly faster and more efficient. Here's an explanation of how the code works: 1. If the length of the input array is 0 or 1, return the original array (since it is already sorted). 2. Choose the first element of the array as the pivot. 3. Create two lists: `less` and `greater`. `less` contains all elements in the array that are less than or equal to the pivot, and `greater` contains all elements that are greater than the pivot. 4. Recursively call the `quicksort` function on the `less` and `greater` lists. 5. Concatenate the results of the recursive calls Copy to clipboard ## Next steps - Learn how to [configure logging to debug applications](https://docs.qualcomm.com/doc/80-88545-1/topic/6_0_logging.html). - Review how to [use CrewAI to create custom agents](https://docs.qualcomm.com/doc/80-88545-1/topic/crewai.html). Last Published: Apr 17, 2026 [Previous Topic Use CrewAI to create agent teams](https://docs.qualcomm.com/bundle/publicresource/80-88545-1/topics/crewai.md) [Next Topic RAG with ChromaDB and LangChain Community](https://docs.qualcomm.com/bundle/publicresource/80-88545-1/topics/rag_with_chromadb.md)