import{s as Sl,n as zl,o as Dl}from"../chunks/scheduler.f9cad8c1.js";import{S as xl,i as Ol,e as U,s as n,c as M,h as Hl,a as J,d as s,b as a,f as Gl,g as y,j as p,k as Wl,l as Yl,m as t,n as m,t as T,o as i,p as o}from"../chunks/index.6e06ef99.js";import{C as Ll,H as Ql,E as Pl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c4302a62.js";import{C as z}from"../chunks/CodeBlock.72594161.js";import{D as ql}from"../chunks/DocNotebookDropdown.77f2c2c1.js";function Kl(Il){let w,O,D,H,r,Y,c,L,C,P,b,dl=`결국 에이전트는 도구와 프롬프트로 이루어진 단순한 구성요소로 정의됩니다.
그리고 무엇보다 중요한 것은 에이전트가 과거 단계의 메모리를 가지고 있어 계획, 실행, 오류의 이력을 추적한다는 점입니다.`,q,V,K,j,gl="과거 실행된 에이전트를 확인하기 위한 몇 가지 기능을 제공합니다.",ll,h,fl='<a href="./inspect_runs">계측 가이드</a>에서 언급한 바와 같이, 에이전트 실행을 계측하여 특정 단계를 확대하거나 축소할 수 있는 우수한 UI로 시각화할 수 있습니다.',el,u,El="또한 다음과 같이 <code>agent.replay()</code>를 사용할 수도 있습니다.",sl,Q,kl="에이전트를 실행한 후,",tl,I,nl,d,Bl="이 마지막 실행을 다시 재생하고 싶다면, 다음 코드를 사용하면 됩니다.",al,g,Ul,f,Jl,E,Rl="많은 고급 사용 사례에서는 에이전트의 메모리를 동적으로 수정해야 합니다.",pl,k,Zl="에이전트의 메모리는 다음과 같이 접근할 수 있습니다.",Ml,B,yl,R,_l="<code>agent.memory.get_full_steps()</code>를 사용하여 전체 단계를 딕셔너리 형태로 가져올 수 있습니다.",ml,Z,Nl="또한 단계 콜백을 사용하여 에이전트의 메모리를 동적으로 변경할 수도 있습니다.",Tl,_,Fl="단계 콜백은 인자로 <code>agent</code> 객체 자체에 접근할 수 있으므로, 위에서 설명한 것처럼 모든 메모리 단계에 접근하여 필요한 경우 수정할 수 있습니다. 예를 들어, 웹 브라우저 에이전트가 수행하는 각 단계의 스크린샷을 관찰하고 있다고 가정해 보겠습니다. 이 경우 최신 스크린샷은 유지하면서 토큰 비용을 절약하기 위해 이전 단계의 이미지를 메모리에서 제거할 수 있습니다.",il,N,vl=`이 경우 다음과 같은 코드를 사용할 수 있습니다.
<em>주의: 이 코드는 간결함을 위해 일부 임포트 및 객체 정의가 생략된 불완전한 예시입니다. 전체 작동 버전의 코드는 <a href="https://github.com/huggingface/smolagents/blob/main/src/smolagents/vision_web_browser.py" rel="nofollow">원본 스크립트</a>에서 확인하세요.</em>`,ol,F,wl,v,Al="그 다음 에이전트를 초기화할 때 이 함수를 다음과 같이 <code>step_callbacks</code> 인수에 전달해야 합니다.",rl,A,cl,$,$l='전체 작동 예시는 <a href="https://github.com/huggingface/smolagents/blob/main/src/smolagents/vision_web_browser.py" rel="nofollow">비전 웹 브라우저 코드</a>에서 확인할 수 있습니다.',Cl,X,bl,G,Xl=`이 기능은 도구 호출에 오랜 시간이 걸리는 경우에 유용합니다.
에이전트를 한 단계씩 실행하면서 각 단계에서 메모리를 업데이트할 수 있습니다.`,Vl,W,jl,S,hl,x,ul;return r=new Ll({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new ql({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/ko/memory.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/ko/pytorch/memory.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/ko/tensorflow/memory.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/ko/memory.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/ko/pytorch/memory.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/ko/tensorflow/memory.ipynb"}]}}),C=new Ql({props:{title:"📚 에이전트 메모리 관리",local:"-manage-your-agents-memory",headingTag:"h1"}}),V=new Ql({props:{title:"에이전트 메모리 재생",local:"replay-your-agents-memory",headingTag:"h3"}}),I=new z({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUyQyUyMENvZGVBZ2VudCUwQSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTJDJTIwdmVyYm9zaXR5X2xldmVsJTNEMCklMEElMEFyZXN1bHQlMjAlM0QlMjBhZ2VudC5ydW4oJTIyV2hhdCdzJTIwdGhlJTIwMjB0aCUyMEZpYm9uYWNjaSUyMG51bWJlciUzRiUyMik=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> InferenceClientModel, CodeAgent

agent = CodeAgent(tools=[], model=InferenceClientModel(), verbosity_level=<span class="hljs-number">0</span>)

result = agent.run(<span class="hljs-string">&quot;What&#x27;s the 20th Fibonacci number?&quot;</span>)`,wrap:!1}}),g=new z({props:{code:"YWdlbnQucmVwbGF5KCk=",highlighted:"agent.replay()",wrap:!1}}),f=new Ql({props:{title:"에이전트 메모리 동적 변경",local:"dynamically-change-the-agents-memory",headingTag:"h3"}}),B=new z({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBBY3Rpb25TdGVwJTBBJTBBc3lzdGVtX3Byb21wdF9zdGVwJTIwJTNEJTIwYWdlbnQubWVtb3J5LnN5c3RlbV9wcm9tcHQlMEFwcmludCglMjJUaGUlMjBzeXN0ZW0lMjBwcm9tcHQlMjBnaXZlbiUyMHRvJTIwdGhlJTIwYWdlbnQlMjB3YXMlM0ElMjIpJTBBcHJpbnQoc3lzdGVtX3Byb21wdF9zdGVwLnN5c3RlbV9wcm9tcHQpJTBBJTBBdGFza19zdGVwJTIwJTNEJTIwYWdlbnQubWVtb3J5LnN0ZXBzJTVCMCU1RCUwQXByaW50KCUyMiU1Q24lNUNuVGhlJTIwZmlyc3QlMjB0YXNrJTIwc3RlcCUyMHdhcyUzQSUyMiklMEFwcmludCh0YXNrX3N0ZXAudGFzayklMEElMEFmb3IlMjBzdGVwJTIwaW4lMjBhZ2VudC5tZW1vcnkuc3RlcHMlM0ElMEElMjAlMjAlMjAlMjBpZiUyMGlzaW5zdGFuY2Uoc3RlcCUyQyUyMEFjdGlvblN0ZXApJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWYlMjBzdGVwLmVycm9yJTIwaXMlMjBub3QlMjBOb25lJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiU1Q25TdGVwJTIwJTdCc3RlcC5zdGVwX251bWJlciU3RCUyMGdvdCUyMHRoaXMlMjBlcnJvciUzQSU1Q24lN0JzdGVwLmVycm9yJTdEJTVDbiUyMiklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbHNlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiU1Q25TdGVwJTIwJTdCc3RlcC5zdGVwX251bWJlciU3RCUyMGdvdCUyMHRoZXNlJTIwb2JzZXJ2YXRpb25zJTNBJTVDbiU3QnN0ZXAub2JzZXJ2YXRpb25zJTdEJTVDbiUyMik=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> ActionStep

system_prompt_step = agent.memory.system_prompt
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;The system prompt given to the agent was:&quot;</span>)
<span class="hljs-built_in">print</span>(system_prompt_step.system_prompt)

task_step = agent.memory.steps[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;\\n\\nThe first task step was:&quot;</span>)
<span class="hljs-built_in">print</span>(task_step.task)

<span class="hljs-keyword">for</span> step <span class="hljs-keyword">in</span> agent.memory.steps:
    <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(step, ActionStep):
        <span class="hljs-keyword">if</span> step.error <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\nStep <span class="hljs-subst">{step.step_number}</span> got this error:\\n<span class="hljs-subst">{step.error}</span>\\n&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\nStep <span class="hljs-subst">{step.step_number}</span> got these observations:\\n<span class="hljs-subst">{step.observations}</span>\\n&quot;</span>)`,wrap:!1}}),F=new z({props:{code:"aW1wb3J0JTIwaGVsaXVtJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGlvJTIwaW1wb3J0JTIwQnl0ZXNJTyUwQWZyb20lMjB0aW1lJTIwaW1wb3J0JTIwc2xlZXAlMEElMEFkZWYlMjB1cGRhdGVfc2NyZWVuc2hvdChtZW1vcnlfc3RlcCUzQSUyMEFjdGlvblN0ZXAlMkMlMjBhZ2VudCUzQSUyMENvZGVBZ2VudCklMjAtJTNFJTIwTm9uZSUzQSUwQSUyMCUyMCUyMCUyMHNsZWVwKDEuMCklMjAlMjAlMjMlMjBKYXZhU2NyaXB0JTIwJUVDJTk1JUEwJUVCJThCJTg4JUVCJUE5JTk0JUVDJTlEJUI0JUVDJTg1JTk4JUVDJTlEJUI0JTIwJUVDJTk5JTg0JUVCJUEzJThDJUVCJTkwJTlDJTIwJUVEJTlCJTg0JUVDJTk3JTkwJTIwJUVDJThBJUE0JUVEJTgxJUFDJUVCJUE2JUIwJUVDJTgzJUI3JUVDJTlEJ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TIwJTNEJTIwZHJpdmVyLmdldF9zY3JlZW5zaG90X2FzX3BuZygpJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKEJ5dGVzSU8ocG5nX2J5dGVzKSklMEElMjAlMjAlMjAlMjBtZW1vcnlfc3RlcC5vYnNlcnZhdGlvbnNfaW1hZ2VzJTIwJTNEJTIwJTVCaW1hZ2UuY29weSgpJTVE",highlighted:`<span class="hljs-keyword">import</span> helium
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<span class="hljs-keyword">from</span> time <span class="hljs-keyword">import</span> sleep

<span class="hljs-keyword">def</span> <span class="hljs-title function_">update_screenshot</span>(<span class="hljs-params">memory_step: ActionStep, agent: CodeAgent</span>) -&gt; <span class="hljs-literal">None</span>:
    sleep(<span class="hljs-number">1.0</span>)  <span class="hljs-comment"># JavaScript 애니메이션이 완료된 후에 스크린샷을 찍도록 합니다.</span>
    driver = helium.get_driver()
    latest_step = memory_step.step_number
    <span class="hljs-keyword">for</span> previous_memory_step <span class="hljs-keyword">in</span> agent.memory.steps:  <span class="hljs-comment"># 이전 스크린샷을 로그에서 제거하여 처리 과정을 간소화합니다.</span>
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(previous_memory_step, ActionStep) <span class="hljs-keyword">and</span> previous_memory_step.step_number &lt;= latest_step - <span class="hljs-number">2</span>:
            previous_memory_step.observations_images = <span class="hljs-literal">None</span>
    png_bytes = driver.get_screenshot_as_png()
    image = Image.<span class="hljs-built_in">open</span>(BytesIO(png_bytes))
    memory_step.observations_images = [image.copy()]`,wrap:!1}}),A=new z({props:{code:"Q29kZUFnZW50KCUwQSUyMCUyMCUyMCUyMHRvb2xzJTNEJTVCV2ViU2VhcmNoVG9vbCgpJTJDJTIwZ29fYmFjayUyQyUyMGNsb3NlX3BvcHVwcyUyQyUyMHNlYXJjaF9pdGVtX2N0cmxfZiU1RCUyQyUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhZGRpdGlvbmFsX2F1dGhvcml6ZWRfaW1wb3J0cyUzRCU1QiUyMmhlbGl1bSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHN0ZXBfY2FsbGJhY2tzJTNEJTVCdXBkYXRlX3NjcmVlbnNob3QlNUQlMkMlMEElMjAlMjAlMjAlMjBtYXhfc3RlcHMlM0QyMCUyQyUwQSUyMCUyMCUyMCUyMHZlcmJvc2l0eV9sZXZlbCUzRDIlMkMlMEEp",highlighted:`CodeAgent(
    tools=[WebSearchTool(), go_back, close_popups, search_item_ctrl_f],
    model=model,
    additional_authorized_imports=[<span class="hljs-string">&quot;helium&quot;</span>],
    step_callbacks=[update_screenshot],
    max_steps=<span class="hljs-number">20</span>,
    verbosity_level=<span class="hljs-number">2</span>,
)`,wrap:!1}}),X=new Ql({props:{title:"에이전트를 단계별로 실행",local:"run-agents-one-step-at-a-time",headingTag:"h3"}}),W=new z({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBJbmZlcmVuY2VDbGllbnRNb2RlbCUyQyUyMENvZGVBZ2VudCUyQyUyMEFjdGlvblN0ZXAlMkMlMjBUYXNrU3RlcCUwQSUwQWFnZW50JTIwJTNEJTIwQ29kZUFnZW50KHRvb2xzJTNEJTVCJTVEJTJDJTIwbW9kZWwlM0RJbmZlcmVuY2VDbGllbnRNb2RlbCgpJTJDJTIwdmVyYm9zaXR5X2xldmVsJTNEMSklMEFhZ2VudC5weXRob25fZXhlY3V0b3Iuc2VuZF90b29scyglN0IqKmFnZW50LnRvb2xzJTdEKSUwQXByaW50KGFnZW50Lm1lbW9yeS5zeXN0ZW1fcHJvbXB0KSUwQSUwQXRhc2slMjAlM0QlMjAlMjJXaGF0JTIwaXMlMjB0aGUlMjAyMHRoJTIwRmlib25hY2NpJTIwbnVtYmVyJTNGJTI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QUMlRUQlOTUlQTklRUIlOEIlODglRUIlOEIlQTQlM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBhZ2VudC5tZW1vcnkuc3RlcHMlNUItMSU1RCUyMCUzRCUyMC4uLiUwQSUwQXByaW50KCUyMlRoZSUyMGZpbmFsJTIwYW5zd2VyJTIwaXMlM0ElMjIlMkMlMjBmaW5hbF9hbnN3ZXIp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> InferenceClientModel, CodeAgent, ActionStep, TaskStep

agent = CodeAgent(tools=[], model=InferenceClientModel(), verbosity_level=<span class="hljs-number">1</span>)
agent.python_executor.send_tools({**agent.tools})
<span class="hljs-built_in">print</span>(agent.memory.system_prompt)

task = <span class="hljs-string">&quot;What is the 20th Fibonacci number?&quot;</span>

<span class="hljs-comment"># 필요에 따라 다른 에이전트의 메모리를 불러와 메모리를 수정할 수 있습니다.</span>
<span class="hljs-comment"># agent.memory.steps = previous_agent.memory.steps</span>

<span class="hljs-comment"># 새로운 작업을 시작합니다!</span>
agent.memory.steps.append(TaskStep(task=task, task_images=[]))

final_answer = <span class="hljs-literal">None</span>
step_number = <span class="hljs-number">1</span>
<span class="hljs-keyword">while</span> final_answer <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">and</span> step_number &lt;= <span class="hljs-number">10</span>:
    memory_step = ActionStep(
        step_number=step_number,
        observations_images=[],
    )
    <span class="hljs-comment"># 한 단계를 실행합니다.</span>
    final_answer = agent.step(memory_step)
    agent.memory.steps.append(memory_step)
    step_number += <span class="hljs-number">1</span>

    <span class="hljs-comment"># 필요한 경우 메모리를 수정할 수도 있습니다</span>
    <span class="hljs-comment"># 예를 들어 최신 단계를 업데이트 하려면 다음과 같이 처리합니다:</span>
    <span class="hljs-comment"># agent.memory.steps[-1] = ...</span>

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;The final answer is:&quot;</span>, final_answer)`,wrap:!1}}),S=new Pl({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/ko/tutorials/memory.md"}}),{c(){w=U("meta"),O=n(),D=U("p"),H=n(),M(r.$$.fragment),Y=n(),M(c.$$.fragment),L=n(),M(C.$$.fragment),P=n(),b=U("p"),b.textContent=dl,q=n(),M(V.$$.fragment),K=n(),j=U("p"),j.textContent=gl,ll=n(),h=U("p"),h.innerHTML=fl,el=n(),u=U("p"),u.innerHTML=El,sl=n(),Q=U("p"),Q.textContent=kl,tl=n(),M(I.$$.fragment),nl=n(),d=U("p"),d.textContent=Bl,al=n(),M(g.$$.fragment),Ul=n(),M(f.$$.fragment),Jl=n(),E=U("p"),E.textContent=Rl,pl=n(),k=U("p"),k.textContent=Zl,Ml=n(),M(B.$$.fragment),yl=n(),R=U("p"),R.innerHTML=_l,ml=n(),Z=U("p"),Z.textContent=Nl,Tl=n(),_=U("p"),_.innerHTML=Fl,il=n(),N=U("p"),N.innerHTML=vl,ol=n(),M(F.$$.fragment),wl=n(),v=U("p"),v.innerHTML=Al,rl=n(),M(A.$$.fragment),cl=n(),$=U("p"),$.innerHTML=$l,Cl=n(),M(X.$$.fragment),bl=n(),G=U("p"),G.textContent=Xl,Vl=n(),M(W.$$.fragment),jl=n(),M(S.$$.fragment),hl=n(),x=U("p"),this.h()},l(l){const e=Hl("svelte-u9bgzb",document.head);w=J(e,"META",{name:!0,content:!0}),e.forEach(s),O=a(l),D=J(l,"P",{}),Gl(D).forEach(s),H=a(l),y(r.$$.fragment,l),Y=a(l),y(c.$$.fragment,l),L=a(l),y(C.$$.fragment,l),P=a(l),b=J(l,"P",{"data-svelte-h":!0}),p(b)!=="svelte-ton0ak"&&(b.textContent=dl),q=a(l),y(V.$$.fragment,l),K=a(l),j=J(l,"P",{"data-svelte-h":!0}),p(j)!=="svelte-1h50h00"&&(j.textContent=gl),ll=a(l),h=J(l,"P",{"data-svelte-h":!0}),p(h)!=="svelte-dnn1cu"&&(h.innerHTML=fl),el=a(l),u=J(l,"P",{"data-svelte-h":!0}),p(u)!=="svelte-iux67r"&&(u.innerHTML=El),sl=a(l),Q=J(l,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-lh7ekp"&&(Q.textContent=kl),tl=a(l),y(I.$$.fragment,l),nl=a(l),d=J(l,"P",{"data-svelte-h":!0}),p(d)!=="svelte-12x9pal"&&(d.textContent=Bl),al=a(l),y(g.$$.fragment,l),Ul=a(l),y(f.$$.fragment,l),Jl=a(l),E=J(l,"P",{"data-svelte-h":!0}),p(E)!=="svelte-1lq08uo"&&(E.textContent=Rl),pl=a(l),k=J(l,"P",{"data-svelte-h":!0}),p(k)!=="svelte-lnzmi9"&&(k.textContent=Zl),Ml=a(l),y(B.$$.fragment,l),yl=a(l),R=J(l,"P",{"data-svelte-h":!0}),p(R)!=="svelte-gjznic"&&(R.innerHTML=_l),ml=a(l),Z=J(l,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-hasgpe"&&(Z.textContent=Nl),Tl=a(l),_=J(l,"P",{"data-svelte-h":!0}),p(_)!=="svelte-hno0dy"&&(_.innerHTML=Fl),il=a(l),N=J(l,"P",{"data-svelte-h":!0}),p(N)!=="svelte-1ie0c2b"&&(N.innerHTML=vl),ol=a(l),y(F.$$.fragment,l),wl=a(l),v=J(l,"P",{"data-svelte-h":!0}),p(v)!=="svelte-v7yafc"&&(v.innerHTML=Al),rl=a(l),y(A.$$.fragment,l),cl=a(l),$=J(l,"P",{"data-svelte-h":!0}),p($)!=="svelte-luwqat"&&($.innerHTML=$l),Cl=a(l),y(X.$$.fragment,l),bl=a(l),G=J(l,"P",{"data-svelte-h":!0}),p(G)!=="svelte-3f8ynb"&&(G.textContent=Xl),Vl=a(l),y(W.$$.fragment,l),jl=a(l),y(S.$$.fragment,l),hl=a(l),x=J(l,"P",{}),Gl(x).forEach(s),this.h()},h(){Wl(w,"name","hf:doc:metadata"),Wl(w,"content",le)},m(l,e){Yl(document.head,w),t(l,O,e),t(l,D,e),t(l,H,e),m(r,l,e),t(l,Y,e),m(c,l,e),t(l,L,e),m(C,l,e),t(l,P,e),t(l,b,e),t(l,q,e),m(V,l,e),t(l,K,e),t(l,j,e),t(l,ll,e),t(l,h,e),t(l,el,e),t(l,u,e),t(l,sl,e),t(l,Q,e),t(l,tl,e),m(I,l,e),t(l,nl,e),t(l,d,e),t(l,al,e),m(g,l,e),t(l,Ul,e),m(f,l,e),t(l,Jl,e),t(l,E,e),t(l,pl,e),t(l,k,e),t(l,Ml,e),m(B,l,e),t(l,yl,e),t(l,R,e),t(l,ml,e),t(l,Z,e),t(l,Tl,e),t(l,_,e),t(l,il,e),t(l,N,e),t(l,ol,e),m(F,l,e),t(l,wl,e),t(l,v,e),t(l,rl,e),m(A,l,e),t(l,cl,e),t(l,$,e),t(l,Cl,e),m(X,l,e),t(l,bl,e),t(l,G,e),t(l,Vl,e),m(W,l,e),t(l,jl,e),m(S,l,e),t(l,hl,e),t(l,x,e),ul=!0},p:zl,i(l){ul||(T(r.$$.fragment,l),T(c.$$.fragment,l),T(C.$$.fragment,l),T(V.$$.fragment,l),T(I.$$.fragment,l),T(g.$$.fragment,l),T(f.$$.fragment,l),T(B.$$.fragment,l),T(F.$$.fragment,l),T(A.$$.fragment,l),T(X.$$.fragment,l),T(W.$$.fragment,l),T(S.$$.fragment,l),ul=!0)},o(l){i(r.$$.fragment,l),i(c.$$.fragment,l),i(C.$$.fragment,l),i(V.$$.fragment,l),i(I.$$.fragment,l),i(g.$$.fragment,l),i(f.$$.fragment,l),i(B.$$.fragment,l),i(F.$$.fragment,l),i(A.$$.fragment,l),i(X.$$.fragment,l),i(W.$$.fragment,l),i(S.$$.fragment,l),ul=!1},d(l){l&&(s(O),s(D),s(H),s(Y),s(L),s(P),s(b),s(q),s(K),s(j),s(ll),s(h),s(el),s(u),s(sl),s(Q),s(tl),s(nl),s(d),s(al),s(Ul),s(Jl),s(E),s(pl),s(k),s(Ml),s(yl),s(R),s(ml),s(Z),s(Tl),s(_),s(il),s(N),s(ol),s(wl),s(v),s(rl),s(cl),s($),s(Cl),s(bl),s(G),s(Vl),s(jl),s(hl),s(x)),s(w),o(r,l),o(c,l),o(C,l),o(V,l),o(I,l),o(g,l),o(f,l),o(B,l),o(F,l),o(A,l),o(X,l),o(W,l),o(S,l)}}}const le='{"title":"📚 에이전트 메모리 관리","local":"-manage-your-agents-memory","sections":[{"title":"에이전트 메모리 재생","local":"replay-your-agents-memory","sections":[],"depth":3},{"title":"에이전트 메모리 동적 변경","local":"dynamically-change-the-agents-memory","sections":[],"depth":3},{"title":"에이전트를 단계별로 실행","local":"run-agents-one-step-at-a-time","sections":[],"depth":3}],"depth":1}';function ee(Il){return Dl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends xl{constructor(w){super(),Ol(this,w,ee,Kl,Sl,{})}}export{Je as component};
