단계 3: Memory Runtime 생성
cd /workspace/workshop-module-2/agentcore-reference && source .venv/bin/activateAgentCore Runtime 생성 (Memory 포함)
python3 << 'PATCH'
import re
f = 'scripts/troubleshooting_agent_runtime_with_memory.py'
c = open(f).read()
if '--disable-memory' in c:
print('Already patched')
else:
c = re.sub(r",\n\s+'--authorizer-config',[^\n]+", "", c)
c = c.replace("'--region', get_aws_region()\n ]",
"'--region', get_aws_region(),\n '--disable-memory'\n ]")
oauth = "f'\\n\\nyes\\n{oauth_discovery_url}\\n{oauth_client_id}\\n\\n\\n\\n' + 'no\\n' * 5"
if 'run_with_pty' in c:
s = c.index(" # Use pseudo-terminal")
e = c.index(" result = run_with_pty(configure_cmd, oauth_input)") + len(" result = run_with_pty(configure_cmd, oauth_input)")
c = c[:s] + f" result = subprocess.run(configure_cmd, check=False, capture_output=True, text=True, timeout=600, shell=False, input={oauth})" + c[e:]
elif "input='no\\n' * 10" in c:
c = c.replace("input='no\\n' * 10", f"input={oauth}")
open(f, 'w').write(c)
print('Patched: PTY -> subprocess.run + --disable-memory')
PATCH검증

코드 분석: Memory Hook 통합
MemoryHook 클래스 전체 구조
on_agent_initialized: 세션 복원
on_message_added: 4가지 전략 라우팅
메모리 강화 시스템 프롬프트 (Module 2 추가분)
규칙
설명
이 시점의 아키텍처
마지막 업데이트