{"id":27004203,"url":"https://github.com/vortezwohl/ceo-autonomous-agent-framework","last_synced_at":"2025-04-04T06:15:21.520Z","repository":{"id":259580854,"uuid":"878264141","full_name":"vortezwohl/CEO-Autonomous-Agent-Framework","owner":"vortezwohl","description":"An ultra-lightweight autonomous agent framework based on the ReAct paradigm.","archived":false,"fork":false,"pushed_at":"2025-04-03T07:13:08.000Z","size":524,"stargazers_count":190,"open_issues_count":13,"forks_count":33,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-03T07:30:56.297Z","etag":null,"topics":["agent","agi","ai","aiagent","autogen","autonomous-agents","framework","langchain","llm-framework","mcp","mcp-agent","mcp-agent-framework","mcp-client","multiagent","nlp","openai","python","tool-learning","tool-oriented-learning","transformer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vortezwohl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-25T04:18:55.000Z","updated_at":"2025-04-03T07:13:11.000Z","dependencies_parsed_at":"2024-10-26T17:53:58.209Z","dependency_job_id":"d2ccaeb1-d268-4eaf-bcb6-6db3b6ac7ca6","html_url":"https://github.com/vortezwohl/CEO-Autonomous-Agent-Framework","commit_stats":null,"previous_names":["vortezwohl/ceo","vortezwohl/ceo-agentic-ai-framework","vortezwohl/ceo-autonomous-agent-framework"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FCEO-Autonomous-Agent-Framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FCEO-Autonomous-Agent-Framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FCEO-Autonomous-Agent-Framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FCEO-Autonomous-Agent-Framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vortezwohl","download_url":"https://codeload.github.com/vortezwohl/CEO-Autonomous-Agent-Framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128753,"owners_count":20888235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","agi","ai","aiagent","autogen","autonomous-agents","framework","langchain","llm-framework","mcp","mcp-agent","mcp-agent-framework","mcp-client","multiagent","nlp","openai","python","tool-learning","tool-oriented-learning","transformer"],"created_at":"2025-04-04T06:15:20.796Z","updated_at":"2025-04-04T06:15:21.511Z","avatar_url":"https://github.com/vortezwohl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cp\u003e\n        \u003cimg src=\"https://github.com/vortezwohl/CEO/releases/download/icon/ceo-icon-inv.png\" alt=\"CEO\" height=\"105\"\u003e\n    \u003c/p\u003e\n    \u003cp style=\"font-weight: 200; font-size: 19px\"\u003e\n        An ultra-lightweight autonomous agent framework based on the \u003ca href=\"https://arxiv.org/abs/2210.03629\"\u003eReAct\u003c/a\u003e paradigm.\n    \u003c/p\u003e\n    \u003cp style=\"font-weight: 200; font-size: 19px\"\u003e\n        \u003ca href=\"https://github.com/modelcontextprotocol\"\u003eMCP\u003c/a\u003e is currently supported. \u003ca href=\"#integration-with-mcp\"\u003eHow to use McpAgent\u003c/a\u003e.\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003ch4 align=\"center\"\u003e\n    \u003cp\u003e\n        \u003cb\u003eEnglish\u003c/b\u003e |\n        \u003ca href=\"https://github.com/vortezwohl/CEO-Agentic-AI-Framework/blob/main/i18n/README_zh-hant.md\"\u003e繁體中文\u003c/a\u003e |\n        \u003ca href=\"https://github.com/vortezwohl/CEO-Agentic-AI-Framework/blob/main/i18n/README_zh-hans.md\"\u003e简体中文\u003c/a\u003e |\n        \u003ca href=\"https://github.com/vortezwohl/CEO-Agentic-AI-Framework/blob/main/i18n/README_ja-jp.md\"\u003e日本語\u003c/a\u003e\n    \u003c/p\u003e\n\u003c/h4\u003e\n\n\u003ch5\u003e\u003c/br\u003e\u003c/h5\u003e\n\n## Abstract\n\nThis research proposes a lightweight and highly robust autonomous agent framework based on the ReAct paradigm, designed to solve complex tasks through adaptive decision-making and multi-agent collaboration. Unlike traditional frameworks that rely on fixed workflows generated by an LLM-based scheduler, this framework dynamically generates next actions during agent execution based on prior trajectories, which enhances their robustness. To address potential termination issues caused by adaptive execution paths, I propose a timely abandonment strategy with a probabilistic penalty mechanism. For multi-agent collaboration, I introduce a memory transfer mechanism that enables shared and dynamically updated memory among agents. The framework's innovative timely abandonment strategy dynamically adjusts the probability of task abandonment via probabilistic penalties, allowing developers to balance conservative and exploratory tendencies in agent execution strategies by tuning hyperparameters. This significantly improves adaptability and task efficiency in complex environments. Additionally, agents can be expanded through external tool use, supported by modular design and MCP protocol compatibility for flexible action space expansion. Through explicit division of labor, the multi-agent collaboration mechanism enables agents to focus on specific task components, thereby significantly improving execution efficiency and quality.\n\n## Experiments\n\nThe experimental results demonstrate that the `ceo-py` framework significantly outperforms `autogen` and `langchain` in handling tasks of varying complexity, especially in multi-step tasks with possible failures.\n\n| Framework   | Version | Model                                      | one-step-task | multi-step-task | multi-step-task-with-possible-failure |\n| ------ | --- |----------------------------------------- | ------------- | --------------- | ---------------------------------------- |\n| `ceo-py` | `0.12.3rc0` |gpt-4o-mini\u003cbr\u003eqwen-plus\u003cbr\u003edeepseek-v3 | 96.7%\u003c/br\u003e100%\u003c/br\u003e100% | 100%\u003c/br\u003e96.7%\u003c/br\u003e100% | 76.7%\u003c/br\u003e93.3%\u003c/br\u003e93.3% |\n| `autogen` | `0.4.9.2` |gpt-4o-mini\u003cbr\u003eqwen-plus\u003cbr\u003edeepseek-v3 |90%\u003c/br\u003e90%\u003c/br\u003eN/A | 53.3%\u003c/br\u003e0%\u003c/br\u003eN/A | 3.3%\u003c/br\u003e3.3%\u003c/br\u003eN/A |\n| `langchain` | `0.3.21` |gpt-4o-mini\u003cbr\u003eqwen-plus\u003cbr\u003edeepseek-v3 | 73.3%\u003c/br\u003e73.3%\u003c/br\u003e76.7% | 13.3%\u003c/br\u003e13.3%\u003c/br\u003e13.3% | 10%\u003c/br\u003e13.3%\u003c/br\u003e6.7% |\n\n- `one-step-task`: Tasks that can be completed with a single tool call.\n- `multi-step-task`: Tasks that require multiple tool calls to complete, with no possibility of tool failure.\n- `multi-step-task-with-possible-failure`: Tasks that require multiple tool calls to complete, where tools may fail, requiring the agent to retry and correct errors.\n\n\u003e The deepseek-v3 model is not supported by `autogen-agentchat==0.4.9.2`.\n\n\u003e You can reproduce my experiments [here](https://github.com/vortezwohl/ceo-experiment).\n\n## Citation\n\nIf you are incorporating the `CEO` framework into your research, please remember to properly **cite** it to acknowledge its contribution to your work.\n\nЕсли вы интегрируете фреймворк `CEO` в своё исследование, пожалуйста, не забудьте правильно сослаться на него, указывая его вклад в вашу работу.\n\nもしあなたが研究に `CEO` フレームワークを組み入れているなら、その貢献を認めるために適切に引用することを忘れないでください.\n\n如果您正在將 `CEO` 框架整合到您的研究中，請務必正確引用它，以聲明它對您工作的貢獻.\n\n```latex\n@software{Wu_CEO-Autonomous-Agent-Framework_2024,\nauthor = {Wu, Zihao},\nlicense = {GPL-3.0},\nmonth = oct,\ntitle = {{CEO-Autonomous-Agent-Framework}},\nurl = {https://github.com/vortezwohl/CEO-Autonomous-Agent-Framework},\nversion = {0.13.1},\nyear = {2024}\n}\n```\n\n## Installation\n\n- From [PYPI](https://pypi.org/project/ceo-py/)\n\n    ```shell\n    pip install ceo-py\n    ```\n\n- From [Github](https://github.com/vortezwohl/CEO/releases)\n\n    Get access to unreleased features.\n\n    ```shell\n    pip install git+https://github.com/vortezwohl/CEO-Agentic-AI-Framework.git\n    ```\n\n## Quick Start\n\nTo start building your own agent, follow the steps listed.\n\n1. set environmental variable `OPENAI_API_KEY`\n\n    ```\n    # .env\n    OPENAI_API_KEY=sk-...\n    ```\n\n2. import required dependencies\n\n    - `Agent` lets you instantiate an agent.\n\n    - `Personality` is an enumeration class used for customizing personalities of agents.\n\n        - `Personality.PRUDENT` makes the agent's behavior more cautious.\n\n        - `Personality.INQUISITIVE` encourages the agent to be more proactive in trying and exploring.\n\n    - `get_openai_model` gives you a `BaseChatModel` as thought engine.\n\n    - `@ability(brain: BaseChatModel, cache: bool = True, cache_dir: str = '')` is a decorator which lets you declare a function as an `Ability`.\n\n    - `@agentic(agent: Agent)` is a decorator which lets you declare a function as an `AgenticAbility`.\n\n    ```python\n    from ceo import (\n        Agent,\n        Personality,\n        get_openai_model,\n        ability,\n        agentic\n    )\n    ```\n\n3. declare functions as basic abilities\n\n    ```python\n    @ability\n    def calculator(expr: str) -\u003e float:\n        # this function only accepts a single math expression\n        return simplify(expr)\n\n    @ability\n    def write_file(filename: str, content: str) -\u003e str:\n        with open(filename, 'w', encoding='utf-8') as f:\n            f.write(content)\n        return f'{content} written to {filename}.'\n    ```\n\n4. instantiate an agent\n\n    You can grant abilities to agents while instantiating them.\n\n    ```python\n    model = get_openai_model()\n    agent = Agent(abilities=[calculator, write_file], brain=model, name='CEO', personality=Personality.INQUISITIVE)\n    ```\n\n    - You can also grant more abilities to agents later:\n\n        ```python\n        agent.grant_ability(calculator)\n        ```\n\n        or\n\n        ```python\n        agent.grant_abilities([calculator])\n        ```\n\n    - To deprive abilities:\n\n        ```python\n        agent.deprive_ability(calculator)\n        ```\n\n        or\n\n        ```python\n        agent.deprive_abilities([calculator])\n        ```\n    \n    You can change an agent's personality using method `change_personality(personality: Personality)`\n\n    ```python\n    agent.change_personality(Personality.PRUDENT)\n    ```\n\n5. assign a request to your agent\n\n    ```python\n    agent.assign(\"Here is a sphere with radius of 9.5 cm and pi here is 3.14159, find the area and volume respectively then write the results into a file called 'result.txt'.\")\n    ```\n\n6. leave the rest to your agent\n\n    ```python\n    response = agent.just_do_it()\n    print(response)\n    ```\n\n\u003e `ceo` also supports multi-agent collaboration scenario, declare a function as agent calling ability with `@agentic(agent: Agent)`, then grant it to an agent. [See example](#multi-agent).\n\n## Integration with [MCP](https://github.com/modelcontextprotocol)\n\nI provide `McpAgent` to support tool calls based on the MCP protocol. Below is a brief guide to integrating `McpAgent` with `mcp.stdio_client`:\n\n1. import required dependencies\n\n    - `McpAgent` allows you to instantiate an agent capable of accessing MCP tools.\n\n    - `StdioMcpConfig` is an alias for `mcp.client.stdio.StdioServerParameters` and serves as the MCP server connection configuration.\n\n    - `@mcp_session(mcp_config: StdioMcpConfig)` allows you to declare a function as an MCP session.\n\n    - `sync_call` allows you to synchronizedly call a coroutine function.\n\n    ```python\n    from ceo import (\n        McpAgent,\n        get_openai_model,\n        StdioMcpConfig,\n        mcp_session,\n        sync_call\n    )\n    ```\n\n2. create an MCP session\n\n    - To connect with a stdio based MCP server, use `StdioMcpConfig`.\n\n        ```python\n        mcp_config = StdioMcpConfig(\n            command='python',\n            args=['./my_stdio_mcp_server.py'],\n            env=dict(),\n            cwd='./mcp_servers'\n        )\n        ```\n\n        \u003e A function decorated with `@mcp_session` will receive an MCP session instance as its first parameter. A function can be decorated with multiple `@mcp_session` decorators to access sessions for different MCP servers.\n\n        ```python\n        @sync_call\n        @mcp_session(mcp_config)\n        async def run(session, request: str) -\u003e str:\n            ...\n        ```\n\n    - To connect via HTTP with a SSE based MCP server, just provide the URL.\n\n        ```python\n        @sync_call\n        @mcp_session('http://localhost:8000/sse')\n        async def run(session, request: str) -\u003e str:\n            ...\n        ```\n    \n    - To connect via websocket with a WS based MCP server, provide the URL.\n\n        ```python\n        @sync_call\n        @mcp_session('ws://localhost:8000/message')\n        async def run(session, request: str) -\u003e str:\n            ...\n        ```\n\n\n3. create an `McpAgent` instance within the MCP session\n\n    After creating `McpAgent`, you need to call the `fetch_abilities()` method to retrieve tool configurations from the MCP server.\n\n    ```python\n    @sync_call\n    @mcp_session(mcp_config)\n    async def run(session, request: str) -\u003e str:\n        mcp_agent = await McpAgent(session=session, brain=model).fetch_abilities()\n        ...\n    ```\n\n4. assign tasks to the `McpAgent` instance and await execution result\n\n    ```python\n    @sync_call\n    @mcp_session(mcp_config)\n    async def run(session, request: str) -\u003e str:\n        mcp_agent = await McpAgent(session=session, brain=model).fetch_abilities()\n        result = await mcp_agent.assign(request).just_do_it()\n        return result.conclusion\n    ```\n\n5. call the function\n\n    ```python\n    if __name__ == '__main__':\n        ret = run(request='What can you do?')\n        print(ret)\n    ```\n\n\u003e I also provide the complete MCP agent test script. [See example](#mcp-agent).\n\n## Observability\n\nTo make the working process of agents observable, I provide two hooks, namely `BeforeActionTaken` and `AfterActionTaken`. \nThey allow you to observe and intervene in the decision-making and execution results of each step of the agent's actions. \nYou can obtain and modify the agent's decision results for the next action through the `BeforeActionTaken` hook, \nwhile `AfterActionTaken` allows you to obtain and modify the execution results of the actions (the tampered execution results will be part of the agent's memory).\n\nTo start using hooks, follow the steps listed.\n\n1. bring in hooks and messages from `CEO`\n\n    ```python\n    from ceo.brain.hook import BeforeActionTaken, AfterActionTaken\n    from ceo.message import BeforeActionTakenMessage, AfterActionTakenMessage\n    ```\n\n2. declare functions and encapsulate them as hooks\n\n    ```python\n    def before_action_taken(agent: Agent, message: BeforeActionTakenMessage):\n        print(f'Agent: {agent.name}, Next move: {message}')\n        return message\n\n    def after_action_taken(agent: Agent, message: AfterActionTakenMessage):\n        print(f'Agent: {agent.name}, Action taken: {message}')\n        return message\n\n    before_action_taken_hook = BeforeActionTaken(before_action_taken)\n    after_action_taken_hook = AfterActionTaken(after_action_taken)\n    ```\n\n    \u003e In these two hook functions, you intercepted the message and printed the information in the message. \n    Afterwards, you returned the message unaltered to the agent. \n    Of course, you also have the option to **modify** the information in the message, \n    thereby achieving intervention in the agent's working process.\n\n3. use hooks during the agent's working process\n\n    ```python\n    agent.assign(...).just_do_it(before_action_taken_hook, after_action_taken_hook)\n    ```\n\n## Examples\n\n- ### Compound Tasks\n\n    1. Find the surface area and volume of a sphere and write the results into a file.\n\n        ```python\n        from ceo import (\n            Agent,\n            Personality,\n            get_openai_model,\n            ability\n        )\n        from ceo.brain.hook import BeforeActionTaken, AfterActionTaken\n        from ceo.message import BeforeActionTakenMessage, AfterActionTakenMessage\n        from sympy import simplify\n        from dotenv import load_dotenv\n\n        load_dotenv()\n\n\n        @ability\n        def calculator(expr: str) -\u003e float:\n            # this function only accepts a single math expression\n            return simplify(expr)\n\n\n        @ability\n        def write_file(filename: str, content: str) -\u003e str:\n            with open(filename, 'w', encoding='utf-8') as f:\n                f.write(content)\n            return f'{content} written to {filename}.'\n\n\n        def before_action_taken(agent: Agent, message: BeforeActionTakenMessage):\n            print(f'Agent: {agent.name}, Next move: {message}')\n            return message\n\n\n        def after_action_taken(agent: Agent, message: AfterActionTakenMessage):\n            print(f'Agent: {agent.name}, Action taken: {message}')\n            return message\n\n\n        if __name__ == '__main__':\n            ceo = Agent(abilities=[calculator, write_file], brain=get_openai_model(), name='CEO', personality=Personality.INQUISITIVE)\n            radius = '(10.01 * 10.36 * 3.33 / 2 * 16)'  # 2762.663904\n            pi = 3.14159\n            output_file = 'result.txt'\n            request = f\"Here is a sphere with radius of {radius} cm and pi here is {pi}, find the area and volume respectively then write the results into a file called '{output_file}'.\"\n            result = ceo.assign(request).just_do_it(BeforeActionTaken(before_action_taken), AfterActionTaken(after_action_taken))  # area = 95910378.2949379, volume = 88322713378.13666\n            print(f'Result: {result}')\n        ```\n\n        ```\n        # result.txt\n        Surface Area: 95910378.2949379 cm²\n        Volume: 88322713378.1367 cm³\n        ```\n\n        ```\n        # stdout\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the simplified result as a float. It is designed to accept a single math expression, ensuring that the input is a valid string representation of a mathematical operation.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '(10.01 * 10.36 * 3.33 / 2 * 16)'})\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '(10.01 * 10.36 * 3.33 / 2 * 16)'}, returns='2762.66390400000', summarization=\"I used the calculator ability to evaluate the expression '(10.01 * 10.36 * 3.33 / 2 * 16)', and the result is 2762.66390400000, which indicates the simplified result of the mathematical operation.\")\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the simplified result as a float. It is designed to accept a single math expression, ensuring that the input is a valid string representation of a mathematical operation.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '4 * 3.14159 * (2762.66390400000^2)'})\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '4 * 3.14159 * (2762.66390400000^2)'}, returns='95910378.2949379', summarization=\"I used the calculator ability to evaluate the expression '4 * 3.14159 * (2762.66390400000^2)', and the result is 95910378.2949379, which represents the simplified calculation of the given mathematical operation.\")\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the simplified result as a float. It is designed to accept a single math expression, ensuring that the input is a valid string representation of a mathematical operation.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '(4/3) * 3.14159 * (2762.66390400000^3)'})\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '(4/3) * 3.14159 * (2762.66390400000^3)'}, returns='88322713378.1367', summarization=\"I used the calculator ability to evaluate the expression '(4/3) * 3.14159 * (2762.66390400000^3)', and the result is 88322713378.1367, which represents the simplified value of the mathematical operation.\")\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"write_file\", \"description\": {\"brief_description\": \"The `write_file` function writes the specified content to a file with the given filename. It takes two parameters: `filename`, which is the name of the file to be created or overwritten, and `content`, which is the string data to be written into the file. Upon successful writing, it returns a confirmation message indicating that the content has been written to the specified file.\"}, \"parameters_required\": [\"filename\", \"content\"], \"returns\": \"\u003cclass 'str'\u003e\"}, arguments={'filename': 'result.txt', 'content': 'Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³'})\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='write_file', arguments={'filename': 'result.txt', 'content': 'Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³'}, returns='Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³ written to result.txt.', summarization=\"I used the write_file ability to write the specified content about surface area and volume to a file named 'result.txt'. The result confirms that the content was successfully written to the file.\")\n        Result: AllDoneMessage(success=True, conclusion=\"Your request has been fully achieved. The calculations resulted in a surface area of 95910378.2949379 cm² and a volume of 88322713378.1367 cm³, which were successfully written to 'result.txt'.\", raw_response=\"--THOUGHT-PROCESS--  \\n(Start) [Calculate radius]: I evaluated the expression '(10.01 * 10.36 * 3.33 / 2 * 16)' and obtained the radius as 2762.66390400000 cm. (--SUCCESS--)  \\n(After: Calculate radius) [Calculate surface area]: I evaluated the expression '4 * 3.14159 * (2762.66390400000^2)' and obtained the surface area as 95910378.2949379 cm². (--SUCCESS--)  \\n(After: Calculate surface area) [Calculate volume]: I evaluated the expression '(4/3) * 3.14159 * (2762.66390400000^3)' and obtained the volume as 88322713378.1367 cm³. (--SUCCESS--)  \\n(After: Calculate volume) [Write results to file]: I wrote the surface area and volume to 'result.txt'. The content was successfully written. (--SUCCESS--)  \\n\\nBased on above assessments, here is my conclusion:  \\n--CONCLUSION--  \\nYour request has been fully achieved. The calculations resulted in a surface area of 95910378.2949379 cm² and a volume of 88322713378.1367 cm³, which were successfully written to 'result.txt'.  \\n--END--\", time_used=62.49354759999551, step_count=4)\n        ```\n\n- ### Multi-agent\n    \n    1. Ask the suitable agents to find the surface area and volume of a sphere and write the results into a file.\n  \n        ```python\n        from sympy import simplify\n        from dotenv import load_dotenv\n        from ceo import (\n            Agent,\n            Personality,\n            get_openai_model,\n            agentic,\n            ability\n        )\n        from ceo.brain.hook import BeforeActionTaken, AfterActionTaken\n        from ceo.message import BeforeActionTakenMessage, AfterActionTakenMessage\n\n        load_dotenv()\n        model = get_openai_model()\n\n\n        @ability(model)\n        def calculator(expr: str) -\u003e float:\n            # this function only accepts a single math expression\n            return simplify(expr)\n\n\n        @ability(model)\n        def write_file(filename: str, content: str) -\u003e str:\n            with open(filename, 'w', encoding='utf-8') as f:\n                f.write(content)\n            return f'{content} written to {filename}.'\n\n\n        jack = Agent(abilities=[calculator], brain=model, name='Jack', personality=Personality.INQUISITIVE)\n        tylor = Agent(abilities=[write_file], brain=model, name='Tylor', personality=Personality.PRUDENT)\n\n\n        @agentic(jack)\n        def agent1():\n            return\n\n\n        @agentic(tylor)\n        def agent2():\n            return\n\n\n        def before_action_taken(agent: Agent, message: BeforeActionTakenMessage):\n            print(f'Agent: {agent.name}, Next move: {message}')\n            return message\n\n\n        def after_action_taken(agent: Agent, message: AfterActionTakenMessage):\n            print(f'Agent: {agent.name}, Action taken: {message}')\n            return message\n\n\n        if __name__ == '__main__':\n            ceo = Agent(abilities=[agent1, agent2], brain=model, name='CEO', personality=Personality.INQUISITIVE)\n            radius = '(10.01 * 10.36 * 3.33 / 2 * 16)'  # 2762.663904\n            pi = 3.14159\n            output_file = 'result.txt'\n            request = f\"Here is a sphere with radius of {radius} cm and pi here is {pi}, find the area and volume respectively then write the results into a file called '{output_file}'.\"\n            result = ceo.assign(request).just_do_it(BeforeActionTaken(before_action_taken), AfterActionTaken(after_action_taken))  # area = 95910378.2949379, volume = 88322713378.13666\n            print(f'Result: {result}')\n        ```\n\n        \u003e In multi-agent collaboration scenario, you can assign different personalities to each distinct agent. For example, in the aforementioned script, Jack's capability is to perform calculations. I want him to try more and explore more, so Jack's personality is set to `Personality.INQUISITIVE`. On the other hand, Taylor's capability is to create and write files. For operations involving interaction with the external file system, I want him to be more cautious, so Taylor's personality is set to `Personality.PRUDENT`.\n\n        ```\n        # result.txt\n        Surface Area: 95910378.2949379 cm²\n        Volume: 88322713378.1367 cm³\n        ```\n\n        ```\n        # stdout\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"__AgenticAbility__talk_to_Jack\", \"description\": {\"brief_description\": \"Initiates a conversation with \\\"Jack\\\" to use its abilities.\", \"detailed_description\": \"First, carefully consider and explore Jack's potential abilities in solving your tasks, then, if you need Jack's help, you must tell comprehensively, precisely and exactly what you need Jack to do.\", \"self_introduction_from_Jack\": \"My name is Jack. What can I do: I can evaluate mathematical expressions as a calculator and provide the result as a float. Additionally, I have the ability to retrieve my personal information, but this can only be done once.\", \"hint\": \"By reading \u003cself_introduction_from_Jack\u003e, you can learn what Jack can do, and then decide whether to initiates a conversation with Jack according to its abilities.\"}, \"parameters_required\": [], \"returns\": \"\u003cclass 'str'\u003e\"}, arguments={'expression': '(10.01 * 10.36 * 3.33 / 2 * 16)'})\n        Agent: Jack, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the result as a float. It uses the `simplify` function to process the expression and ensure it is correctly computed.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '(10.01 * 10.36 * 3.33 / 2 * 16)'})\n        Agent: Jack, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '(10.01 * 10.36 * 3.33 / 2 * 16)'}, returns='2762.66390400000', summarization=\"I used the calculator ability to evaluate the expression '(10.01 * 10.36 * 3.33 / 2 * 16)', and the result is '2762.66390400000', which indicates the computed value of the mathematical expression.\")\n        Agent: Jack, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the result as a float. It uses the `simplify` function to process the expression and ensure it is correctly computed.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '4 * 3.14159 * (2762.66390400000^2)'})\n        Agent: Jack, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '4 * 3.14159 * (2762.66390400000^2)'}, returns='95910378.2949379', summarization=\"I used the calculator ability to evaluate the expression '4 * 3.14159 * (2762.66390400000^2)', resulting in the value '95910378.2949379'.\")\n        Agent: Jack, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"calculator\", \"description\": {\"brief_description\": \"The `calculator` function evaluates a mathematical expression provided as a string and returns the result as a float. It uses the `simplify` function to process the expression and ensure it is correctly computed.\"}, \"parameters_required\": [\"expr\"], \"returns\": \"\u003cclass 'float'\u003e\"}, arguments={'expr': '(4/3) * 3.14159 * (2762.66390400000^3)'})\n        Agent: Jack, Action taken: AfterActionTakenMessage(ability='calculator', arguments={'expr': '(4/3) * 3.14159 * (2762.66390400000^3)'}, returns='88322713378.1367', summarization=\"I used the calculator ability to evaluate the expression '(4/3) * 3.14159 * (2762.66390400000^3)', and the result is 88322713378.1367, which represents the computed volume of a sphere with a radius of approximately 2762.66.\")\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='__AgenticAbility__talk_to_Jack', arguments={'arguments': 'Ask for a favor.'}, returns='{\"success\": false, \"response\": \"--THOUGHT-PROCESS--  \\\\n(Initial calculation) [Calculate radius]: I calculated the radius as \\'2762.66390400000\\' cm. (--SUCCESS--)  \\\\n(After: Calculate radius) [Calculate surface area]: I calculated the surface area using the formula \\'4 * 3.14159 * (2762.66390400000^2)\\', resulting in \\'95910378.2949379\\'. (--SUCCESS--)  \\\\n(After: Calculate surface area) [Calculate volume]: I calculated the volume using the formula \\'(4/3) * 3.14159 * (2762.66390400000^3)\\', resulting in \\'88322713378.1367\\'. (--SUCCESS--)  \\\\n(After: Calculate volume) [Write results to file]: There is no record in \u003chistory\u003e indicating that the results were written to \\'result.txt\\'. (--FAILED--)  \\\\n\\\\nBased on above assessments, here is my conclusion:  \\\\n--CONCLUSION--  \\\\nYour request has not been fully achieved. I calculated the radius as \\'2762.66390400000\\' cm, the surface area as \\'95910378.2949379\\', and the volume as \\'88322713378.1367\\', but the results were not written to \\'result.txt\\'.  \\\\n--END--\"}', summarization=\"I used the __AgenticAbility__talk_to_Jack ability to ask Jack for a favor. Jack calculated the radius, surface area, and volume of a sphere, but failed to write the results to 'result.txt'.\")\n        Agent: CEO, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"__AgenticAbility__talk_to_Tylor\", \"description\": {\"brief_description\": \"Initiates a conversation with \\\"Tylor\\\" to use its abilities.\", \"detailed_description\": \"First, carefully consider and explore Tylor's potential abilities in solving your tasks, then, if you need Tylor's help, you must tell comprehensively, precisely and exactly what you need Tylor to do.\", \"self_introduction_from_Tylor\": \"My name is Tylor. What can I do: I can write content to a file and provide my personal information upon request, but the latter can only be used once.\", \"hint\": \"By reading \u003cself_introduction_from_Tylor\u003e, you can learn what Tylor can do, and then decide whether to initiates a conversation with Tylor according to its abilities.\"}, \"parameters_required\": [], \"returns\": \"\u003cclass 'str'\u003e\"}, arguments={'file_name': 'result.txt', 'content': 'Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³'})\n        Agent: Tylor, Next move: BeforeActionTakenMessage(ability={\"ability_name\": \"write_file\", \"description\": {\"brief_description\": \"The `write_file` function writes the specified content to a file with the given filename. It opens the file in write mode, encodes the content in UTF-8, and returns a confirmation message indicating that the content has been successfully written to the file.\"}, \"parameters_required\": [\"filename\", \"content\"], \"returns\": \"\u003cclass 'str'\u003e\"}, arguments={'filename': 'result.txt', 'content': 'Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³'})\n        Agent: Tylor, Action taken: AfterActionTakenMessage(ability='write_file', arguments={'filename': 'result.txt', 'content': 'Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³'}, returns='Surface Area: 95910378.2949379 cm²\\nVolume: 88322713378.1367 cm³ written to result.txt.', summarization=\"I used the write_file ability to write the specified content about surface area and volume to a file named 'result.txt'. The result confirms that the content was successfully written to the file.\")\n        Agent: CEO, Action taken: AfterActionTakenMessage(ability='__AgenticAbility__talk_to_Tylor', arguments={'arguments': 'Ask for a favor.'}, returns='{\"success\": true, \"response\": \"--THOUGHT-PROCESS--  \\\\n(Initial calculation) [Calculate radius]: The radius was calculated as \\'2762.66390400000\\' cm. (--SUCCESS--)  \\\\n(After: Calculate radius) [Calculate surface area]: The surface area was calculated using the formula \\'4 * 3.14159 * (2762.66390400000^2)\\', resulting in \\'95910378.2949379\\'. (--SUCCESS--)  \\\\n(After: Calculate surface area) [Calculate volume]: The volume was calculated using the formula \\'(4/3) * 3.14159 * (2762.66390400000^3)\\', resulting in \\'88322713378.1367\\'. (--SUCCESS--)  \\\\n(After: Calculate volume) [Write results to file]: The results were successfully written to \\'result.txt\\'. (--SUCCESS--)  \\\\n\\\\nBased on above assessments, here is my conclusion:  \\\\n--CONCLUSION--  \\\\nYour request has been fully achieved. The radius was calculated as \\'2762.66390400000\\' cm, the surface area as \\'95910378.2949379\\' cm², and the volume as \\'88322713378.1367\\' cm³. The results were successfully written to \\'result.txt\\'.  \\\\n--END--  \"}', summarization=\"I used the __AgenticAbility__talk_to_Tylor ability to ask Tylor for a favor, which involved calculating the radius, surface area, and volume of a sphere. The results were successfully computed and written to 'result.txt'.\")\n        Result: AllDoneMessage(success=True, conclusion=\"Your request has been fully achieved. The radius was calculated as '2762.66390400000' cm, the surface area as '95910378.2949379' cm², and the volume as '88322713378.1367' cm³. The results were successfully written to 'result.txt'.\", raw_response=\"--THOUGHT-PROCESS--  \\n(Initial calculation) [Calculate radius]: The radius was calculated as '2762.66390400000' cm. (--SUCCESS--)  \\n(After: Calculate radius) [Calculate surface area]: The surface area was calculated using the formula '4 * 3.14159 * (2762.66390400000^2)', resulting in '95910378.2949379' cm². (--SUCCESS--)  \\n(After: Calculate surface area) [Calculate volume]: The volume was calculated using the formula '(4/3) * 3.14159 * (2762.66390400000^3)', resulting in '88322713378.1367' cm³. (--SUCCESS--)  \\n(After: Calculate volume) [Write results to file]: The results were successfully written to 'result.txt'. (--SUCCESS--)  \\n\\nBased on above assessments, here is my conclusion:  \\n--CONCLUSION--  \\nYour request has been fully achieved. The radius was calculated as '2762.66390400000' cm, the surface area as '95910378.2949379' cm², and the volume as '88322713378.1367' cm³. The results were successfully written to 'result.txt'.  \\n--END--  \", time_used=123.79718699998921, step_count=2)\n        ```\n\n- ### MCP Agent\n\n    1. Ask a browser-use augmented mcp agent to search for and find out what RL is.\n\n        ```python\n        from ceo import (\n            McpAgent,\n            get_openai_model,\n            ability,\n            sync_call,\n            StdioMcpConfig,\n            __BLOG__\n        )\n        from ceo.util.mcp_session import mcp_session\n        from ceo.brain.hook import BeforeActionTaken, AfterActionTaken\n        from ceo.message import BeforeActionTakenMessage, AfterActionTakenMessage\n        from dotenv import load_dotenv\n\n        load_dotenv()\n        model = get_openai_model()\n        stdio_mcp_config = StdioMcpConfig(\n            command='python',\n            args=['./playwright-plus-python-mcp.py'],\n            env=dict(),\n            cwd='./mcp_server'\n        )\n\n\n        @ability(model)\n        def write_file(filename: str, content: str) -\u003e str:\n            with open(filename, 'w', encoding='utf-8') as f:\n                f.write(content)\n            return f'{content} written to {filename}.'\n\n\n        def before_action_taken(agent: McpAgent, message: BeforeActionTakenMessage):\n            print(f'Agent: {agent.name}, Next move: {message.ability.name}')\n            return message\n\n\n        def after_action_taken(agent: McpAgent, message: AfterActionTakenMessage):\n            print(f'Agent: {agent.name}, Action taken: {message.summarization}')\n            return message\n\n\n        @sync_call\n        @mcp_session(stdio_mcp_config)\n        async def run(session, request: str) -\u003e str:\n            mcp_agent = await McpAgent(session=session, brain=model).fetch_abilities()\n            mcp_agent.grant_ability(write_file)\n            result = await mcp_agent.assign(request).just_do_it(\n                BeforeActionTaken(before_action_taken),\n                AfterActionTaken(after_action_taken)\n            )\n            return result.conclusion\n\n\n        if __name__ == '__main__':\n            output_file = 'result.txt'\n            request = (f'What is reinforcement learning? Bing (www.bing.com) it and write down the search results into local file: {output_file}. '\n                    f'Then navigate to {__BLOG__}.')\n            ret = run(request)\n            print(ret)\n\n        ```\n\n        ```\n        # result.txt\n        Reinforcement Learning: An Overview\n        Reinforcement Learning (RL)\n        Key Concepts of Reinforcement Learning\n        Agent: The learner or decision-maker.\n        Agent\n        Environment: Everything the agent interacts with.\n        Environment\n        State: A specific situation in which the agent finds itself.\n        State\n        Action: All possible moves the agent can make.\n        Action\n        Reward: Feedback from the environment based on the action taken\n        1.\n        Reward\n        How Reinforcement Learning Works\n        IBM\n        https://www.ibm.com › think › topics › reinforcement-learning\n        What is reinforcement learning? | IBM\n        2024年3月25日 · In reinforcement learning, an agent learns to make decisions by interacting with an environment. It is used in robotics and other decision-making settings. Reinforcement …\n        2024年3月25日\n        Wikipedia\n        https://en.wikipedia.org › wiki › Reinforcement_learning\n        Reinforcement learning - Wikipedia\n        Overview\n        Principles\n        Exploration\n        Algorithms for control learning\n        Theory\n        Research\n        Comparison of key algorithms\n        Statistical comparison of reinforcement learning algorithms\n        machine learning\n        optimal control\n        intelligent agent\n        take actions\n        maximize a reward\n        three basic machine learning paradigms\n        supervised learning\n        unsupervised learning\n        Wikipedia · CC-BY-SA 许可下的文字\n        · CC-BY-SA 许可下的文字\n        CC-BY-SA 许可\n        预计阅读时间：10 分钟\n        其他用户还问了以下问题\n        What are reinforcement learning algorithms?\n        Reinforcement learning encompasses a variety of algorithms. Some of the most notable include: Q-learning is a model-free, value-based algorithm that learns an action-value function (Q-function) to estimate the expected cumulative reward for taking a given action in a given state.\n        Q-learning\n        What is reinforcement learning? - cudocompute.com\n        cudocompute.com\n        What is reinforcement learning (RL)?\n        Reinforcement learning (RL) is a type of machine learning process that focuses on decision making by autonomous agents. An autonomous agent is any system that can make decisions and act in response to its environment independent of direct instruction by a human user. Robots and self-driving cars are examples of autonomous agents.\n        ```\n\n        ```\n        # stdout\n        Agent: 智能體47239e型號, Next move: playwright_navigate\n        Agent: 智能體47239e型號, Action taken: I utilized the **playwright_navigate** ability to navigate to the URL \"https://www.bing.com/search?q=What+is+reinforcement+learning\". The result confirms that the navigation was successful, and the page content includes search results related to \"reinforcement learning\", such as articles from IBM, Wikipedia, and other sources. This operation successfully retrieved the desired webpage content for further processing or analysis.\n        Agent: 智能體47239e型號, Next move: write_file\n        Agent: 智能體47239e型號, Action taken: I used the `write_file` ability to write a detailed overview of Reinforcement Learning into a file named \"result.txt\". The content included key concepts such as Agent, Environment, State, Action, and Reward, along with additional information from sources like IBM and Wikipedia. The result confirms that the content was successfully written to the specified file.\n        Agent: 智能體47239e型號, Next move: playwright_navigate\n        Agent: 智能體47239e型號, Action taken: I used the playwright_navigate ability to navigate to the URL \"https://vortezwohl.github.io\". The result confirms that the navigation was successful, and the page content includes text such as \"vortezwohl\", \"About\", \"Years\", \"Categories\", \"Tags\", and various blog post titles related to reinforcement learning, machine learning concepts, and other technical topics.\n        Your request has been fully achieved. I searched for \"What is reinforcement learning\" on Bing, retrieved relevant information, and wrote it into a file named \"result.txt\". Subsequently, I navigated to the website \"https://vortezwohl.github.io\", confirming that the navigation was successful and the page content was as expected.\n        ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvortezwohl%2Fceo-autonomous-agent-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvortezwohl%2Fceo-autonomous-agent-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvortezwohl%2Fceo-autonomous-agent-framework/lists"}