From Noisy Traces to Root Causes: Structural Trajectory Analysis and Causal Extraction for Agent Optimization
TL;DR Highlight
Agent 실패 로그를 인과 그래프로 분석해 진짜 근본 원인만 골라내고, 해당 모듈 프롬프트만 정밀하게 수정하는 자동 최적화 프레임워크
Who Should Read
GPT-4o, o4-mini 기반 멀티 에이전트 시스템을 운영하면서 실패 원인을 찾고 프롬프트를 개선하려는 AI 엔지니어. 특히 장기(long-horizon) 태스크에서 에이전트가 왜 실패하는지 디버깅이 어려운 상황에 있는 개발자.
Core Mechanics
- Agent 실행 로그를 단순 텍스트가 아니라 의존성 그래프(Execution Dependency Graph)로 모델링해서, Step 50의 에러가 실제로는 Step 5의 잘못된 결정에서 비롯됐음을 추적할 수 있음.
- 배치 단위로 실패 패턴을 마이닝해서 중복 로그를 제거하고 대표 실패 케이스만 남기는 trace filtering을 수행 — 453개 로그에서 소수의 exemplar만 선택해 최적화 비용을 통제.
- 오류가 드러난 지점(Manifestation Node)과 실제 원인 지점(Root Cause Node)을 구분하고, 의존성 역방향 탐색(backward slicing)으로 인과적으로 관련된 스텝만 추출한 compact causal slice를 만듦.
- 추출된 causal slice를 바탕으로 인스턴스별 패치가 아닌 재사용 가능한 일반화된 휴리스틱 규칙을 생성하고, 해당 근본 원인 모듈의 프롬프트에만 주입 — 코드 수정 없이 프롬프트만 업데이트.
- Claude Sonnet 4.5를 메타 컨트롤러로 사용하고, 실제 에이전트 백본은 GPT-4o(HotpotQA/WebArena)와 o4-mini(VeruSAGE-Bench)를 사용해 실험.
- 전체 파이프라인 비용은 $2.96 수준으로, Trace Filtering 없이 실행하면 $8.45, 전체 trace를 그대로 쓰면 $5.93으로 비용이 급증.
Evidence
- VeruSAGE-Bench(Rust 코드 형식 검증 태스크)에서 Base Agent 42.5% → STRACE 58.5%로 +16.0%p 개선, 2위 GEPA(47.2%) 대비 +11.3%p 차이.
- WebArena 전체 성공률: Base Agent 10.8% → STRACE 23.7%(+12.9%p), TextGrad 17.3%, GEPA 16.5% 대비 압도적 우위.
- HotpotQA Exact Match: Base Agent 37.0% → STRACE 68.5%, 가장 강한 베이스라인인 GEPA(64.4%) 대비 +4.1%p.
- STRACE로 최적화된 o4-mini가 GPT-5 hands-off 에이전트(50.0%)를 능가하고(58.5%), Claude Sonnet 4 hands-off(59.4%)와 대등한 성능 — 더 작은 모델로 더 큰 모델 수준 달성.
- VeruSAGE에서 평균 수리 턴 수가 IronKV 기준 12.04 → 8.42, NRKernel 14.83 → 8.20으로 감소해 효율도 개선됨.
How to Apply
- 멀티 에이전트 시스템을 운영 중이라면, 실패한 실행 로그를 모아 에이전트 코드베이스에서 모듈 간 data/control dependency를 먼저 텍스트 엣지 리스트로 추출 — LLM에게 README, 설정파일, 에이전트 정의를 읽혀서 그래프 자동 생성 가능.
- 대량의 실패 로그가 쌓였을 때, 각 로그의 global 성공/실패 여부와 어느 노드에서 에러가 났는지를 파싱해 P(Task Fail | Node Fail) 통계를 내고 중요한 실패 패턴 클러스터에서 대표 케이스만 선별 — 나머지 중복 로그는 버려도 됨.
- 단일 에이전트(WebArena처럼 프롬프트 하나짜리)에도 적용 가능 — 이 경우 dependency graph 없이 causal slicing을 타임스텝 단위로 적용하고, 생성된 휴리스틱을 해당 에이전트의 instruction에 append하면 됨.
Code Example
# STRACE 4단계 파이프라인 개념 구현 스케치
# Phase 1: Execution Dependency Graph 구성
system_prompt_phase1 = """
You are analyzing an agent system repository.
Identify all functional modules (V) and infer edges (E) between them:
- Data dependency: Module B consumes artifacts produced by Module A
- Control dependency: Module A governs whether Module B is invoked
Output as a text edge list:
<edges>
module_A -> module_B : data | artifact: intermediate_plan
module_A -> module_C : control | condition: error_type == 'syntax'
</edges>
"""
# Phase 2: 실패 패턴 요약 및 trace 필터링
failure_summary_prompt = """
Given execution traces, compute:
1. Statistical Severity: P(Task Fail | Node_i Fail) for each module
2. Structural Path Patterns: recurring pathological sequences (loops, dead-ends)
Select {s} representative traces covering distinct failure clusters.
"""
# Phase 3: Causal Localization - backward slicing
causal_localization_prompt = """
Given:
- Manifestation Node (vm): where error surfaces
- Dependency Graph (G)
- Execution Trace
Step 1: Starting from vm, traverse dependency edges BACKWARD.
Retain only steps reachable via Data/Control dependency closure.
This is the Causal Slice (C_slice).
Step 2: Within C_slice, identify Root Cause Node (vr):
The earliest module where execution first deviated from intended logic.
Example: Code Interpreter (vm) crashed because Planner (vr) hallucinated
a parameter 45 steps earlier.
Output:
- Causal Slice: [step_1, step_5, step_12, step_48]
- Root Cause Node: planner_module
- Root Cause Explanation: ...
"""
# Phase 4: 귀납적 정책 최적화
policy_optimization_prompt = """
Given causal slices from multiple failures all traced to root cause module: {vr}
Synthesize GENERALIZED heuristic rules (not instance-specific patches):
- Identify recurring failure patterns across episodes
- Abstract into reusable preventive guidelines
- Format as instruction additions for the module's system prompt
Example output:
"When attempting action X more than 2 times with consistent rejection,
switch to alternative action Y. Track attempt counts per action type."
Inject these rules ONLY into module {vr}'s prompt.
"""
# GitHub: https://github.com/moomight/STRACETerminology
Related Papers
Show HN: FableCut – A browser video editor AI agents can drive (zero deps)
타임라인 전체를 JSON 파일 하나로 표현하고 MCP/REST로 AI 에이전트가 직접 편집할 수 있는 브라우저 비디오 에디터로, Claude 같은 AI가 프롬프트 하나로 영상을 자동 컷편집하고 결과를 실시간으로 UI에 반영해준다.
Show HN: Microsoft releases Flint, a visualization language for AI agents
Microsoft가 LLM/AI 에이전트가 차트를 쉽게 생성할 수 있도록 설계된 고수준 시각화 DSL(도메인 특화 언어) Flint를 오픈소스로 공개했다. 에이전트가 복잡한 시각적 세부사항 대신 의미론적 명세만 다루면 되도록 추상화 계층을 제공하는 게 핵심이다.
Think Big, Search Small: Where Capacity Matters in Hierarchical Search Agents?
멀티에이전트 검색 시스템에서 큰 모델은 질문 분해에, 작은 모델은 실제 검색 실행에 쓰는 게 정답이다.
Geosql: A Claude/Codex skill for geospatial data
PostGIS, BigQuery, Snowflake 등에서 지리공간 데이터를 다룰 때 Claude/Codex/GitHub Copilot에 설치해서 SQL 생성과 지도 렌더링까지 자동화해주는 오픈소스 Skill이다.
GitLost: We Tricked GitHub's AI Agent into Leaking Private Repos
Noma Security 연구팀이 GitHub의 새 AI 에이전트 워크플로우에서 Prompt Injection 취약점을 발견했고, 인증 없이 공개 이슈 하나만으로 조직 내 private 저장소 내용을 외부에 노출시키는 데 성공했다.
AI Meets Cryptography 1: What AI Found in Cloudflare's Circl
zkSecurity 팀이 AI 감사 파이프라인을 Cloudflare의 오픈소스 암호화 라이브러리 CIRCL에 돌려서 실제로 존재하는 버그 7개를 발견했고, 그 중에는 속성 기반 암호화의 접근 제어를 완전히 우회할 수 있는 Critical 버그도 포함되어 있다. AI가 암호화 코드 감사에서 실질적인 성과를 낼 수 있음을 보여준 사례라 주목할 만하다.
Related Resources
Original Abstract (Expand)
The optimization of long-horizon agents increasingly relies on reflection-based mechanisms, where a large language model (LLM) acts as an optimizer to diagnose agent failures and improve agent policies. However, real execution traces are difficult to use directly for optimization: large trace collections are often redundant and heterogeneous, making optimization inefficient and prone to overfitting to low-value failures; meanwhile, each individual trajectory also contains many irrelevant steps, while naive context reduction methods such as truncation or sliding windows can discard causally important evidence and produce misleading optimization signals. To resolve this dilemma, we introduce STRACE (Structural TRajectory Analysis and Causal Extraction), a framework that constructs high signal-noise optimization contexts for more precise and effective optimization. At the batch level, STRACE mines failure patterns to filter redundant traces and retain representative failures; within each selected trace, it performs causal localization over a textual dependency graph to remove non-causal steps and identify the true root-cause module for optimization. Empirical results demonstrate that STRACE significantly outperforms standard context-filtering baselines. Notably, on a challenging formal verification task (VeruSAGE-Bench), it successfully optimizes human-expert designed agents, delivering $1.4\times$ success-rate improvement (42.5% to 58.5%). The code is available at https://github.com/moomight/STRACE .