How OpenClaw Works (and why you should build your own)

Agentic Lab www.youtube.com

간략한 요약

이 비디오에서는 OpenClaw라는 AI 에이전트의 작동 방식과 핵심 원리를 설명하고, 특정 사용 사례에서 OpenClaw보다 5~10배 더 뛰어난 성능을 발휘하는 자체 에이전트를 구축하는 방법을 안내합니다. OpenClaw는 LLM을 중심으로 구축된 툴 세트로, 다양한 작업을 수행할 수 있도록 설계되었습니다. 하지만 범용 모델이기 때문에 특정 작업에 불필요한 컨텍스트가 과도하게 주어지는 경향이 있어 성능 저하 및 비용 증가를 초래할 수 있습니다. 따라서 이 비디오에서는 특정 목적에 맞춰 컨텍스트를 최적화한 "저격 에이전트(sniper agents)"를 구축하는 것을 권장합니다.

  • OpenClaw의 아키텍처와 작동 원리 이해
  • AI 에이전트 구축의 4가지 핵심 원리
  • 특정 목적에 최적화된 에이전트 구축의 이점

소개

OpenClaw는 LLM을 기반으로 구축되어 다양한 작업을 수행할 수 있는 AI 에이전트입니다. 이 비디오에서는 OpenClaw의 내부 작동 방식과 핵심 원리를 살펴보고, 이를 바탕으로 특정 사용 사례에서 더 뛰어난 성능을 발휘하는 자체 에이전트를 구축하는 방법을 설명합니다.

"AGI" 사용 사례

OpenClaw의 특별한 점을 보여주는 예시로, 에이전트가 스스로 시작하여 브라우저를 열고, X(구 트위터)에서 최신 AI 관련 게시물을 검색하여 주요 내용을 요약한 후 사용자에게 메시지를 보내는 시나리오를 소개합니다. 이 모든 과정이 사용자의 개입 없이 완전 자동으로 이루어집니다.

OpenClaw의 작동 방식

OpenClaw는 LLM을 핵심 두뇌로 사용하며, 텔레그램과 같은 인터페이스를 통해 LLM과 통신할 수 있도록 게이트웨이를 연결합니다. LLM은 API 호출 사이에 정보를 기억하지 못하므로, OpenClaw는 JSONL 파일에 대화 내용을 저장하여 세션 지속성을 유지합니다. 대화가 길어지면 모델의 컨텍스트 창이 넘치게 되는데, 이때 OpenClaw의 압축 시스템이 작동하여 이전 메시지를 요약하고 컨텍스트 크기를 줄입니다. 모델에게 도구와 개성을 부여하기 위해 시스템 프롬프트, 기술 메타데이터, 도구 스키마 등을 제공합니다. 또한, 모델이 중요한 정보를 기억할 수 있도록 메모리 파일에 쓰기 권한을 부여하고, RAG 스타일의 메모리를 추가하여 이전 대화 내용을 저장하고 검색할 수 있도록 합니다. 에이전트가 수행할 수 있는 작업은 도구 호출을 통해 정의되며, 도구는 외부 작업을 트리거하고 결과를 모델에 다시 전달하여 에이전트 루프를 형성합니다. OpenClaw는 크롬 확장 프로그램을 통해 브라우저를 제어하고, 터미널 및 카메라와 같은 컴퓨터의 모든 기능에 접근할 수 있습니다. 자율적인 동작은 하트비트(일정 시간마다 에이전트를 깨우는 프롬프트)와 크론 작업(예약된 작업)을 통해 구현됩니다.

AI 에이전트 구축의 4가지 핵심 원리

AI 에이전트는 크게 4가지 범주로 구성됩니다. 첫째, 에이전트를 트리거하는 요인(크론, 하트비트 등). 둘째, 매 턴마다 LLM의 컨텍스트에 주입되는 정보(시스템 프롬프트, 대화 기록, 도구 스키마 등). 셋째, LLM이 호출할 수 있는 도구(메모리 검색, 컴퓨터 제어, 기술, 플러그인 등). 넷째, 에이전트의 출력 또는 쓰기(에이전트가 수행할 수 있는 작업 및 통신 방법). 에이전트가 루프에서 실행되도록 하는 것도 중요합니다. LLM은 도구를 호출하고, 도구로부터 피드백을 받고, 다음 단계를 결정합니다.

자체 에이전트를 구축해야 하는 이유

OpenClaw는 범용 모델이기 때문에 특정 작업에 불필요한 컨텍스트가 과도하게 주어지는 경향이 있습니다. 이로 인해 성능 저하 및 비용 증가가 발생할 수 있습니다. 또한, OpenClaw는 보안 취약점이 존재하고, 사용자 정의가 어렵습니다. 따라서 특정 목적에 맞춰 컨텍스트를 최적화한 "저격 에이전트"를 구축하는 것이 좋습니다. OpenClaw는 시작 시 고정 오버헤드가 높고, 시간이 지남에 따라 메모리 파일 및 기술이 증가하면서 컨텍스트가 비대해져 성능이 저하될 수 있습니다. 반면, 단일 목적 에이전트는 필요한 토큰 수가 적고 성능 저하가 적습니다. OpenClaw는 메모리, 하트비트, 기술 등에 제한이 있어 장기간 사용 시 정보 손실이 발생할 수 있습니다. 에이전트 및 하네스 작동 방식을 이해하면 범용 모델보다 훨씬 뛰어난 성능을 얻을 수 있습니다. OpenClaw의 내부 메커니즘을 이해하면 컨텍스트 관리를 통해 컨텍스트 비대화를 방지할 수 있습니다.

유튜브 영상을 몇 초 만에 요약하세요

무료 Summ 앱으로 어떤 영상이든 이런 요약을 원하는 언어로 받아보세요.

App Store에서 다운로드
Google Play에서 다운로드

스크립트

“How OpenClaw Works (and why you should build your own)”의 전체 스크립트입니다. 타임스탬프를 클릭하면 해당 장면부터 영상이 열려요. 다른 영상이 필요하다면 유튜브 스크립트 추출기를 이용하세요.

0:00 OpenClaw is an AI agent that's taken the world by storm. So much so that people are calling it AGI. In this video, I'll show you exactly how it works under the hood and the fundamentals that let you build your own agents that outperform it 5 to 10x on your specific use case. I'm Roman. I published a top 3% paper at Nurips, the largest AI conference in the world. Now I'm on a mission to become the best AI coder. So what is openclaw really? At its core, it's a set of building blocks around an LLM that gives it the ability to perform a variety of tasks. Think of it like an exoskeleton built around the LLM, giving it the capacity to perform complex tasks on a computer.

0:45 So here's a motivating example of what makes OpenClaw feel so special. Your agent wakes up on its own, opens up your browser. While logged into your account, it starts scouring X for the latest AI discourse. It reads through the post, pulls out the key takeaways, and shoots you a message. Here's your morning briefing. All of this happens completely autonomously without you lifting a finger. But this isn't magic, and it actually is relatively simple to understand how OpenClaw actually works. First, we start with an LLM, which would typically be a very simple external API call or local model. This is the entire brains of the operation. But if we want to talk to it from a chat interface, especially our phone, we can route

1:32 Telegram or other channels to it. So, we connect to a gateway, which is typically a websocket and HTTP server, and it runs 24/7, and it ties everything together. Since LLMs forget everything between API calls, we need session persistence. The way chatbots work is they paste the entire conversation back into the next API call. OpenClaw does this by appending every message as a line to a JSON L file on disk. On each API call, that file is parsed into a messages array and passed back to the LLM. But long conversations eventually overflow the model's context window. When the API rejects the request is too large, OpenClaw's compaction system kicks in.

2:20 It summarizes each chunk of prior messages via the LLM, merges the summaries and retries until the context is below 50%. So now we have set up a basic chatbot. Hence, we need to get the model to understand that it isn't just a simple LLM and that it has tools and a personality. The solution here is simple. We give the model a system prompt which is a set of markdown files which tell it how to work in the openclaw harness. These include soul agents and memory. On top of that, we give the LLM skills metadata and tool schemas so that it knows which tool it can actually call without giving it the entire tool or skill into its context. Finally, we also inject some safety and runtime prompts that help the model

3:06 operate safely. And to make the chatbot remember who we are and previous conversations, we allow the model to write to a previously mentioned memory.mmd file for critical information. And openclot also adds in a rag style memory which uses a hybrid retrieval system in order to store tons of previous conversations and nuggets. It then allows the model to call a memory tool in order to search the memory database for relevant details. We also have an output function which is just where the LLM talks to us. It might output to telegram, discord or somewhere else. Since we have provided the model with an identity, we have to actually tell it which actions it can take and how. This is the exoskeleton. We call

3:52 these tool calls. The model can output some tokens which calls the tool. The tool triggers an external action to occur. For example, writing code in the computer and the tool returns tokens back to the model. and a feedback loop is hence created. We call this an agentic loop. Your OpenClaw is now an agent. One of the most critical tools that makes OpenCloud different from most agents is that of computer control. OpenClaw controls your browser via a Chrome extension relay similar to Claude browser. And this means OpenClaw can stay logged in. Also, it's not just browser access. It's full-on computer control with access to everything from the terminal to the camera. Obviously, this level of access comes with heavy

4:38 security trade-offs. So, please use your at your own risk and with heavy guardrails. But the big thing that OpenCloud gets so much praise for is its autonomous behavior. This is actually built on two relatively simple mechanisms. The first is the heartbeat, a timer which is defaulted to every 30 minutes that fires a standard prompt telling the agent to recall heartbeat.mmd and follow its instructions. The key insight here is that the agent itself can write to heartbeat.mmd. So it effectively programs its own future behavior. On top of this, there are cron jobs which are scheduled tasks the agent can create, modify and delete using the cron tool with full cron expressions, one-time triggers or intervals. The other method

5:24 is web hooks which are external events that wake the agent with context about the trigger. Something happens, the model wakes up with that context and it acts on it. And there it is. For the most part, this is the entire architecture behind OpenClaw. Most of these are wired to the model through various scripts and hooks. Obviously, there are features and methodologies that I can't explain in just a simple video like this, such as multi-agent methods, hooks, sandboxing, and more. And you can notice a distinct pattern here. Agents are comprised of four categories. What triggers the agent, what is injected on every turn, what tools it can call, and what it outputs. And the final gem is giving the agents

6:10 the ability to run in a loop. The LLM calls a tool, gets feedback on the tool, and decides the next step. Putting all of this together is what we call a harness. And learning to build your own is one of the highest levered skills going into the next decade. Think of it like the newer version of coding. And all you need to start are these four categories of model behavior. Let's break down each zone. First, what triggers the LLM? Cron, heartbeats, these are all core methods to wake OpenClaw or the LLM up. Next, what gets injected into the LLM's context on every turn? The system prompt with soul.md in this case, and personality files, JSON L

6:55 conversation history tool schemas. Basically, you want to give the model just enough information to operate well without giving it too much information and causing context rot. Then we have the tools the LLM can actually call. Examples might be memory retrieval via rag, computer control, skills, plugins, all executing in a sandboxed environment with results flowing back to the model in an agentic loop. This makes your model an actual agent. And finally, what the agent outputs or writes. This answers the question of what the agent can actually do and how it can actually communicate with the world and remember. So, OpenClaw is genuinely impressive, but the truth is that it's a generalist

7:41 model. The OpenClaw architecture is just a roundabout way of giving one agent the power to do many, many things. As a result, the context given to OpenClaw is consistently overkill for a given task. and they have to jump through many many hoops. This is the core reason that OpenClaw doesn't perform as well as you would like and tends to be very very expensive. On top of all of this, Anthropic banned OpenClaw use on max plans. OpenClaw has a massive security vulnerability and OpenClaw is very different, very difficult to truly customize and see what's going on inside. For this reason, I implore you to build your own version that serves just one purpose. I call these sniper agents. Let me give you a

8:29 motivating example of open claused context. So, on day one, you're looking at about 7,000 tokens of fixed overhead before you even say a word. This is honestly impressively low. And typically, it's comprised of the soul.md agents, workspace files, skill descriptions, tool schemas, and more. But here's where things get bad. After a month of daily use, memory files grow. The agent creates skills. Every session reset, saves a summary file, and more. The more skills and plugins you install, the more bloated things get. At this point, you're looking at around 45,000 tokens of fixed overhead before even sending a single prompt. based on the results of the paper measuring context

9:14 rot. This results in up to a 40% performance decrease in your model. But look at a singlepurpose email reader agent. It only needs about 1,400 tokens and it works like a charm. After 6 months, the workspace files cap at around 37,000 tokens, the skills cap at 7,500 tokens, and tools can get infinite bloat, resulting in tens of thousands of tokens. At those token counts, you're looking at at least 50 to 90% performance decreases and about 52 cents of extra usage per message sent. And by the way, once again, this is before you even send your first message. That will result in almost instant compaction.

10:00 So on top of all of this, OpenClaw has hard limits on certain functionalities such as memory, heartbeat, skills, and more. This causes absolutely catastrophic forgetting after months of daily use. The model will forget what you told it because open claw is directly preventing those memories from getting into context. It does this by very basic truncation. So something I want you to take away is that learning how agents and harnesses will work will allow insane performance gains above a one-sizefits-all model. And at very least, understanding OpenClaw's internal mechanisms will allow you to prevent context rot by maintaining good context hygiene and limiting plug-in usage. If you want to

10:46 learn more about how to build agents that will streamline your work or help you build your dream app, join my free school community. It is the number one agentic coding community on school. Thanks for watching and I'll

Share

다른 영상 요약