SAFARI: Active Investigation 기반의 장거리 Agentic Fault Attribution 확장
SAFARI: Scaling Long Horizon Agentic Fault Attribution via Active Investigation
TL;DR Highlight
수백만 토큰 넘는 에이전트 실행 로그에서 버그 발생 지점을 찾아내는 도구 기반 진단 프레임워크
Who Should Read
멀티 에이전트 시스템을 운영하면서 실패 원인을 추적하거나 에이전트 모니터링 파이프라인을 구축하는 AI 엔지니어. 긴 실행 트레이스에서 LLM context 한계로 인해 오류 진단이 안 되는 문제를 겪고 있는 개발자.
Core Mechanics
- 기존 fault attribution(에이전트 실행 중 어디서 실패했는지 찾는 작업) 방법은 전체 trajectory를 LLM context에 통째로 올리는데, 트레이스가 수백만 토큰에 달하면 context 한계를 초과해서 아예 동작 불가.
- SAFARI는 전체 트레이스를 한번에 읽는 대신, read(offset, limit)와 search(pattern) 두 도구를 써서 LLM이 필요한 구간만 선택적으로 조회하는 'Active Investigation' 루프를 돌림.
- Short-Term Memory(STM)를 유지해서 오래된 대화 내용이 context에서 밀려나더라도 핵심 가설, 증거, 조사 계획을 잃지 않고 유지함.
- 가설을 최대 3개의 원자적 클레임(atomic claim)으로 분해한 후 별도 Reasoning Evaluator LLM에 병렬로 검증 요청하고, 평균 신뢰도 점수가 70 이상이면 결론을 내리는 2단계 검증 구조.
- backbone LLM으로 Claude-Opus-4.6(1M token)을 사용하며, 최대 30번의 tool call 반복 후에는 'forced finalization'으로 지금까지 모은 증거로 최선의 답을 강제 출력.
- fault가 context 윈도우 밖에 있을 때(ς > 1) 기존 방법들은 아예 동작을 못 하지만, SAFARI는 Active Investigation으로 context 밖 구간도 도구로 탐색 가능.
Evidence
- Who&When 벤치마크(1M token 예산)에서 기존 SOTA인 RAFFLES 대비 20% 높은 정확도 달성.
- TRAIL GAIA 서브셋에서 25K token 예산 제약 조건 하에 RAFFLES 대비 precision 7%, strict precision 19% 향상.
- fault 위치가 native context의 5배 밖에 있는 극단 시나리오(ς=5)에서도 precision 0.58 유지. 기존 방법들은 이 구간에서 precision 0으로 완전 실패.
- 100K token 예산의 SAFARI가 1M token 예산의 RAFFLES와 동등한 성능을 보여, 토큰 예산 10분의 1로도 같은 결과.
How to Apply
- 멀티 에이전트 시스템의 실행 로그가 LLM context를 초과할 때, 전체 로그를 프롬프트에 넣는 대신 read(offset, limit)와 search(pattern) 도구를 에이전트에 쥐어주고 가설 기반으로 필요한 구간만 조회하게 설계하면 됨.
- 에이전트가 여러 턴에 걸쳐 조사할 때 이전 발견 사항이 context에서 밀려나는 문제는, STM 구조체(task_goal, faults_identified_so_far, still_need, past_tool_calls)를 매 턴 프롬프트 끝에 붙여서 해결 가능.
- 최종 결론 전에 가설을 3개의 원자적 질문으로 쪼개서 별도 LLM에 검증 요청하는 패턴을 쓰면, 에이전트 자체 평가의 환각(hallucination)을 줄이고 신뢰도를 높일 수 있음.
Code Example
# SAFARI STM 구조 예시 - 매 턴 프롬프트에 삽입
stm_template = """
<stm>
{
"task_goal": "[분석 중인 에이전트 시스템의 목표]",
"final_output": "[마지막 스텝의 출력과 왜 틀렸는지]",
"faults_identified_so_far": [
{
"step_id": 3,
"reason": "이 스텝이 최초 오류이고, 이후 수정되지 않은 이유",
"evidence": "트레이스에서 직접 인용한 증거 (300자 이내)"
}
],
"still_need": ["step 5를 읽어서 tool call 실패 여부 확인"]
}
</stm>
NEXT ACTION: [다음에 호출할 도구와 이유]
"""
# 도구 정의 예시 (OpenAI function calling 형식)
tools = [
{
"type": "function",
"function": {
"name": "read",
"description": "트레이스의 특정 구간을 읽음",
"parameters": {
"type": "object",
"properties": {
"offset": {"type": "integer", "description": "시작 라인 번호"},
"limit": {"type": "integer", "description": "읽을 라인 수 (최소 80 권장)"}
},
"required": ["offset", "limit"]
}
}
},
{
"type": "function",
"function": {
"name": "search",
"description": "트레이스에서 정규식 패턴 검색",
"parameters": {
"type": "object",
"properties": {
"pattern": {"type": "string", "description": "검색할 정규식 패턴"}
},
"required": ["pattern"]
}
}
},
{
"type": "function",
"function": {
"name": "evaluate",
"description": "원자적 질문으로 가설 검증 (submit 전 필수)",
"parameters": {
"type": "object",
"properties": {
"questions": {"type": "array", "items": {"type": "string"}, "maxItems": 3},
"reasoning": {"type": "string", "description": "트레이스 인용 포함한 근거"}
},
"required": ["questions", "reasoning"]
}
}
}
]Terminology
관련 논문
RubyLLM: 주요 AI 프로바이더를 모두 지원하는 Ruby 프레임워크
OpenAI, Claude, Gemini 등 주요 AI 프로바이더를 단일 인터페이스로 통합한 Ruby 프레임워크로, Rails 통합과 에이전트 기능까지 지원해 Ruby 개발자가 AI 기능을 빠르게 붙일 수 있다.
Qwen-AgentWorld: 범용 에이전트를 위한 Language World Model
Alibaba Qwen 팀이 AI 에이전트가 행동 결과를 미리 시뮬레이션할 수 있는 'Language World Model'을 공개했다. 에이전트 훈련과 실행 경로 검증에 새로운 패러다임을 제시하는 연구다.
SHERLOC: Code Repair Agent를 위한 구조화된 Diagnostic Localization 프레임워크
버그 위치만 알려주는 게 아니라 '왜, 어떻게 고쳐야 하는지'까지 진단 리포트를 생성해서 코드 수정 에이전트의 성능을 높이는 training-free 프레임워크
peerd – 브라우저에서 완전히 실행되는 AI Agent Harness
백엔드 서버 없이 Chrome/Firefox 확장 프로그램으로만 동작하는 AI 에이전트 실행 환경으로, 브라우저 탭을 직접 조작하고 WASM Linux VM까지 구동할 수 있어 프라이버시와 보안을 동시에 챙길 수 있다.
Self-Compacting Language Model Agents: Rubric 기반 적응형 Context 압축
LLM 에이전트가 스스로 '지금 요약해도 되는지'를 판단하는 rubric을 추가하면, 파인튜닝 없이도 고정 주기 요약보다 정확도는 높고 비용은 30~70% 낮아진다.
Oak – AI 에이전트를 위해 설계된 Git 대안 VCS
AI 에이전트가 코드 작업을 더 효율적으로 수행할 수 있도록 설계된 새로운 버전 관리 시스템(VCS)으로, lazy mount, JSON-first CLI, 멀티 레포 에이전트 워크스페이스 등을 제공한다. 다만 커뮤니티에서는 Git 대비 실질적 우위가 충분히 증명되지 않았다는 회의적 반응이 많다.
Related Resources
Original Abstract (Expand)
As autonomous agents tackle increasingly complex multi-step, multi-agent tasks, their execution trajectories have scaled beyond the constraints of even the largest context windows. Current methods for effectively diagnosing agent failures load the full trajectory into an LLM's context window, which suffers from attention dilution and fails when agentic traces inevitably exceed context limits. To address this, we introduce SAFARI (Scaling long-horizon Agentic Fault AttRibution via active Investigation), a framework that replaces linear context loading with a tool-augmented diagnostic loop. By equipping LLMs with a specialized toolbox to read and search trajectory segments alongside a persistent Short-Term Memory (STM) for cross-turn reasoning, SAFARI effectively decouples diagnostic accuracy from architectural context limits. Our experiments demonstrate that SAFARI outperforms state-of-the-art results by 20% on the Who&When dataset within a 1M token budget, and by 19% on TRAIL GAIA subset on a 25K token budget. Most significantly, SAFARI maintains a 0.58 precision even when the target fault resides 5x beyond the model's native context window, a scenario where traditional evaluators fail entirely.