RAG Agent는 무엇인가: Workflow에서 상태 기반 제어 루프로 (1/10)
고정 RAG pipeline을 observe·decide·act·evaluate 상태 루프로 바꾸고, LLM과 deterministic harness의 책임을 분리해 종료 조건·예산·불변식·실패 상태를 가진 첫 RAG Agent를 Python으로 구현합니다.
Series · Folio
상태 루프부터 안전한 운영 하네스까지 이어지는 초·중급 10편
고정 RAG pipeline을 observe·decide·act·evaluate 상태 루프로 바꾸고, LLM과 deterministic harness의 책임을 분리해 종료 조건·예산·불변식·실패 상태를 가진 첫 RAG Agent를 Python으로 구현합니다.
LLM의 tool call을 실제 API 실행과 분리하고 JSON Schema 입력 계약, 의미·권한 검증, 구조화된 결과와 오류 envelope, side-effect·idempotency·version metadata를 갖춘 안전한 tool registry를 설계합니다.
질문의 지식 필요성·신선도·식별자·복잡도·모호성·위험도를 판별해 no retrieval, direct lookup, single·iterative search, clarification을 선택하고 routing regret로 검증하는 RAG router를 설계합니다.
ReAct, plan-execute, ReWOO, tree search를 비용과 적응성으로 비교하고 dependency·success criteria·failure policy를 가진 plan DAG와 replan trigger·stop rule을 설계합니다.
질문을 evidence requirement로 분해하고 relevance·coverage·support·contradiction·freshness를 판정해 Self-RAG·CRAG·FLARE식 재검색·확인 질문·안전 종료를 bounded loop로 구현합니다.
Agent state·context·memory·corpus를 구분하고 working·episodic·semantic·procedural memory의 write·retrieve·update·forget lifecycle을 provenance·유효 기간·ACL·민감도로 설계합니다.
프로세스·네트워크 장애 뒤에도 RAG Agent를 안전하게 재개하도록 checkpoint·replay·idempotency·timeout·retry·cancellation·compensation을 설계합니다.
RAG Agent의 router·retrieval·model·tool·checkpoint를 trace·span·event·artifact로 연결하고 version·비용·latency·error를 기록해 최초 실패 지점을 재현합니다.
검색 문서와 tool result를 untrusted data로 격리하고 provenance·taint·최소 capability·human approval·commit-time authorization으로 Agent 부작용과 정보 유출을 막습니다.
State·tool·router·evidence·memory·durable runtime·trace·security를 production harness로 통합하고 final state와 trajectory의 품질·비용·보안 gate로 안전하게 릴리스합니다.