- 로컬에서 AI 에이전트 실행
- 여러 도구 및 API 통합: 외부 API, 로컬 모델 및 자동화 도구를 연결, 호출
- 워크플로우 사용자 지정: AI가 복잡한 다단계 상호 작용을 효율적으로 처리
- 여러 LLM 지원: LLaMA, Mistral 및 Mixtral과 같은 인기 있는 개방형 모델 모델과 호환
- 자동화 향상: 내장 메모리 및 계획 기능을 통해 OpenManus는 코딩, 문서 처리, 연구 등을 지원
pydantic, openai, fastapi, tiktoken, html2text, unicorn, googlesearch-python, playwright, docker
실행결과는 많이 알려진 프롬프트를 제외하고는 그다지 품질이 좋지는 않다. 그럼에도, 나름 많은 스타를 깃허브에서 얻고 있는 오픈 마누스의 에이전트의 구조를 분석하는 것은 의미가 있어 보여, 좀 더 자세히 코드를 확인해 본다.
I need a 7-day Japan itinerary for April 15-23 from Seattle, with a $2500-5000 budget for my fiancée and me. We love historical sites, hidden gems, and Japanese culture (kendo, tea ceremonies, Zen meditation). We want to see Nara's deer and explore cities on foot. I plan to propose during this trip and need a special location recommendation. Please provide a detailed itinerary and a simple HTML travel handbook with maps, attraction descriptions, essential Japanese phrases, and travel tips we can reference throughout our journey.
- call main() # 메인 호출
- prompt = input() # 프롬프트 입력
- Manus.BaseAgent.run(prompt) # 프롬프트 입력에 따른 에이전트 도구들 실행
- update_memory() # 과거 입출력 저장
- max_steps 만큼 아래 루프 반복 # default max_steps = 20
- step_result = ReActAgent.step() # 에이전트 도구 단계별 실행
- should_act = think() # 무슨 도구를 순서대로 호출할 지 LLM통해 정보얻음
- recent_messages = memory.messages[-3:]
- Manus.BrowserAgent.ToolCallAgent.think() # 도구 선택 추론
- extract current browser page information # 웹화면 정보 사용
- response = LLM.ask_tool() # 추론 시 LLM 사용
- check token limit # 토큰 한계 체크
- response = ChatCompletion(params) # LLM 호출
- return response[0].message # 결과 리턴
- return response
- act() # 에이전트 도구가 선택되었으니, 이를 실행
- tool_callls 에 담긴 도구 호출 명령에 따른 도구들 실행 루프 수행
- ToolCallAgent.execute_tool(command) # 도구 실행
- args = json.loads(command) # 예. web_search. '7-day tour'
- ToolCollection.execute(args) # 도구집합에서 해당도구실행
- BrowserUseTool.execute(args) # 쿼리검색 후 link 리턴
- _ensure_browser_initialized() #브라우저 초기화
- links = WebSearch.execute(args.query) # 웹서치
- page = get_current_page() # 페이지정보
- result = page.goto(url_to_navigate)
- return ToolResult(args, result) # 검색결과 수집
- return observation(result)
- tool_msg = 도구 실행 명령 및 함수 정보
- memory.add_message(tool_msg) # 메모리 업데이트
- results.append(result)
- return results # 결과리턴
1. 프로그램 시작: 메인 함수 호출2. 프롬프트 입력: 사용자로부터 프롬프트 입력3. 에이전트 실행: BaseAgent가 입력을 기반으로 동작 시작4. 메모리 업데이트: 과거 입력/출력 내용을 memory에 저장5. 에이전트 루프 실행 (기본 max_steps = 20)5.1. 단계 실행 (Step): ReActAgent가 현재 단계 처리 시작5.2. 다음 행동 판단 (Think)5.2.1. 최근 메시지 3개 불러오기5.2.2. LLM을 통해 다음 행동(도구 호출 여부 등) 추론5.3. Think: 도구 선택 판단5.3.1. BrowserAgent가 어떤 도구를 쓸지 결정5.3.2. 현재 브라우저 페이지 정보 추출5.3.3. 필요 시 LLM에 도구 사용 목적 질의 (ask_tool)5.3.4. 토큰 한계 체크5.4. LLM 호출 및 응답5.4.1. ChatCompletion으로 명령 생성5.4.2. 생성된 메시지 반환5.5. Act: 도구 실행 (Act)5.5.1. 도구 호출 명령(command)을 파싱 (예: JSON)반복 (모든 명령에 대한 도구 실행):5.5.2. 도구 실행 수행5.5.2.1. ToolCollection에서 해당 도구 실행5.5.2.2. 브라우저 초기화 (_ensure_browser_initialized)5.5.2.3. 웹 검색 수행 (WebSearch.execute)5.5.2.4. 페이지 이동 및 정보 추출 (page.goto)5.5.3. 도구 결과 처리5.5.3.1. ToolResult로 실행 결과 정리5.5.3.2. observation 형태로 결과 정리5.6. 메모리 및 결과 저장5.6.1. 도구 실행 정보 및 결과를 memory에 저장5.6.2. 결과 리스트에 추가6. 최종 결과 반환: 누적된 결과 또는 마지막 응답을 사용자에게 반환
"Based on user needs, proactively select the most appropriate tool or combination of tools. For complex tasks, you can break down the problem and use different tools step by step to solve it. After using each tool, clearly explain the execution results and suggest the next steps."
SYSTEM_PROMPT = ("You are OpenManus, an all-capable AI assistant, aimed at solving any task presented by the user. You have various tools at your disposal that you can call upon to efficiently complete complex requests. Whether it's programming, information retrieval, file processing, or web browsing, you can handle it all.""The initial directory is: {directory}")NEXT_STEP_PROMPT = """Based on user needs, proactively select the most appropriate tool or combination of tools. For complex tasks, you can break down the problem and use different tools step by step to solve it. After using each tool, clearly explain the execution results and suggest the next steps."""
결론적으로 핵심만 요약해 보면, 다음과 같은 방식으로 에이전트가 실행되는 것을 확인 할 수 있다.
- 사용자 프롬프트 입력
- LLM 이 프롬프트를 통해 어떤 에이전트 도구들을 실행할 지 결정. 도구 정보 반환
- 도구 호출 정보에 따라, 현재 등록된 도구들을 호출. 결과 파일은 workspace에 저장
- 도구 호출 결과는 메모리에 저장. 이는 LLM 이 도구를 호출할 때 참고 컨텐츠로 재사용
- 사용자 프롬프트 요구사항(목표)을 만족할 때까지 앞의 내용 반복
소프트웨어 공학적으로는 디자인패턴 중 strategy pattern (ToolCollection, BaseTool) 을 사용하고 있다. 나머진 일반적인 OOAD 구조이다.
BaseTool 클래스는 execute 메서드를 공통으로 가지며, 이를 상속한 각 도구 클래스들(Terminal, FileSaver, MCPClientTool, WebSearch, DomService, BrowserUseTool 등)은 시스템 명령 실행, 파일 저장, 브라우저 제어 등 특정 기능을 담당한다. 각 도구는 ToolCollection에 집합되어 있으며, tool_map을 통해 관리되고 execute를 통해 실행된다.
ToolCallAgent는 think 메서드를 통해 어떤 도구를 사용할지 판단하고, 판단 결과를 ToolCollection에 전달하여 해당 도구를 실행한다. ReActAgent는 step, think, act 메서드를 통해 LLM 기반 추론과 도구 실행 흐름을 단계적으로 처리하며, BaseAgent는 이를 상속받아 step 단위의 실행 흐름을 제공한다. Manus 객체는 최상위 제어자로서 전체적인 에이전트의 동작을 통제하며 think 메서드를 통해 추론을 담당한다. BrowserAgent는 BrowserUseTool과 관련된 think 역할을 수행한다.
BrowserUseTool은 WebSearch와 DomService를 포함하며 웹 페이지 탐색, 클릭, 입력 등의 브라우저 상의 조작을 담당한다. DomService는 클릭, 스크롤, 탭 전환 등 구체적인 DOM 제어 명령을 담당하며, 오른쪽 enum 박스는 이 DomService가 수행할 수 있는 구체적인 명령어 목록을 나열한 것이다.
LLM 클래스는 ask_tool, ask_with_images, ask 등의 메서드를 제공하며, 도구 선택 판단 또는 일반 자연어 추론을 위한 언어 모델 호출 기능을 수행한다. LLM이 사용하는 모델은 gpt-4-vision, gpt-4.0, claude-3 계열 등으로 구성된 멀티모달 모델 리스트에 명시되어 있다.
전체 구조는 에이전트가 사용자 입력을 받아 LLM을 통해 판단하고, 적절한 도구를 선택하여 실행하며, 이를 반복적으로 수행하는 다단계 추론 및 실행 체계를 중심으로 구성되어 있다.
- OpenManus: the Open-Source Alternative to Manus AI
- OpenManus: No fortress, purely open ground. OpenManus is Coming.
- OpenManus-RL: A live stream development of RL tunning for LLM agents
- Manus AI: The Best Autonomous AI Agent Redefining Automation and Productivity
- The First General AI Agent Unveiled, 2025, Medium
- Manus use cases
- Exploring Manus AI Agent. Autonomous AI Revolution and How to Get… , Naveen Krishnan, 2025, Towards AI
- Langflow, Low-code AI builder for agentic and RAG applications
- Langflow is a powerful tool for building and deploying AI-powered agents and workflows
- OpenManus reddit
댓글 없음:
댓글 쓰기