"<!DOCTYPE html>\n<html lang=\"zh\" data-theme=\"light\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>fulltext.txt — Vercel Design System</title>\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap\" rel=\"stylesheet\">\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css\">\n<style>\n\n:root {\n  /* Vercel Palette */\n  --geist-foreground: #171717;\n  --geist-background: #ffffff;\n  --geist-secondary: #4d4d4d;\n  --geist-tertiary: #666666;\n  --geist-quaternary: #808080;\n  --geist-border: #ebebeb;\n  --geist-surface-tint: #fafafa;\n  \n  /* Workflow Accents */\n  --develop-blue: #0a72ef;\n  --preview-pink: #de1d8d;\n  --ship-red: #ff5b4f;\n  \n  /* Interactive & Status */\n  --link-blue: #0072f5;\n  --ds-focus-color: hsla(212, 100%, 48%, 1);\n  --badge-blue-bg: #ebf5ff;\n  --badge-blue-text: #0068d6;\n  \n  /* Shadow-as-Border Philosophy */\n  --shadow-border: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(0, 0, 0, 0.16) 0px 0px 0px 1px;\n  --shadow-card: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(0, 0, 0, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.06) 0px 4px 6px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-full: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, rgba(0, 0, 0, 0.04) 0px 8px 8px -8px, #fafafa 0px 0px 0px 1px;\n  --shadow-ring: rgb(235, 235, 235) 0px 0px 0px 1px;\n  \n  /* Radius Scale */\n  --radius-xs: 2px;\n  --radius-sm: 4px;\n  --radius-md: 6px;\n  --radius-lg: 8px;\n  --radius-xl: 12px;\n  --radius-pill: 9999px;\n}\n\n[data-theme=\"dark\"] {\n  --geist-foreground: #ededed;\n  --geist-background: #000000;\n  --geist-secondary: #a1a1a1;\n  --geist-tertiary: #888888;\n  --geist-quaternary: #666666;\n  --geist-border: #222222;\n  --geist-surface-tint: #0a0a0a;\n  \n  --shadow-border: rgba(255, 255, 255, 0.14) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(255, 255, 255, 0.28) 0px 0px 0px 1px;\n  --shadow-card: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.4) 0px 2px 4px, #111111 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(255, 255, 255, 0.2) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 6px 12px, #111111 0px 0px 0px 1px;\n  --shadow-card-full: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 8px 16px -4px, #111111 0px 0px 0px 1px;\n  --shadow-ring: rgb(40, 40, 40) 0px 0px 0px 1px;\n  \n  --badge-blue-bg: rgba(10, 114, 239, 0.15);\n  --badge-blue-text: #70b5ff;\n}\n\n* { box-sizing: border-box; }\nhtml { scroll-behavior: smooth; }\nbody {\n  margin: 0;\n  font-family: \"Geist\", Arial, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n  background-color: var(--geist-background);\n  color: var(--geist-foreground);\n  font-feature-settings: \"liga\" 1;\n  -webkit-font-smoothing: antialiased;\n  min-height: 100vh;\n}\n\na {\n  color: inherit;\n  text-decoration: none;\n  transition: color 0.15s ease;\n}\n\n/* 导航栏 (Vercel Clean Sticky Nav) */\n.vercel-nav {\n  position: sticky;\n  top: 0;\n  background-color: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  z-index: 100;\n  padding: 0 24px;\n  height: 64px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n.nav-brand {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n.vercel-triangle {\n  width: 22px;\n  height: 19px;\n  fill: var(--geist-foreground);\n}\n.nav-title {\n  font-size: 16px;\n  font-weight: 600;\n  letter-spacing: -0.32px;\n  color: var(--geist-foreground);\n}\n.nav-badge-pill {\n  font-family: \"Geist Mono\", ui-monospace, monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  background: var(--badge-blue-bg);\n  color: var(--badge-blue-text);\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n}\n\n.nav-links {\n  display: flex;\n  align-items: center;\n  gap: 24px;\n}\n.nav-link {\n  font-size: 14px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.nav-link:hover, .nav-link.active {\n  color: var(--geist-foreground);\n}\n.nav-link.active {\n  font-weight: 600;\n}\n\n.nav-actions {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n/* 按钮规范 */\n.btn-primary-dark {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: opacity 0.15s;\n}\n.btn-primary-dark:hover {\n  opacity: 0.9;\n}\n.btn-secondary-white {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: background 0.15s, box-shadow 0.15s;\n}\n.btn-secondary-white:hover {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border-hover);\n}\n.theme-toggle-btn {\n  background: transparent;\n  border: none;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  width: 36px;\n  height: 36px;\n  cursor: pointer;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  color: var(--geist-foreground);\n}\n\n/* 核心容器 */\n.vercel-container {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 56px 24px 100px;\n}\n\n/* Hero Section (Gallery Emptiness + Negative Letter-spacing) */\n.vercel-hero {\n  text-align: center;\n  max-width: 860px;\n  margin: 0 auto 56px;\n}\n.hero-stage-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 4px 14px;\n  border-radius: var(--radius-pill);\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  margin-bottom: 24px;\n}\n.stage-dot {\n  width: 7px;\n  height: 7px;\n  border-radius: 50%;\n}\n.vercel-hero h1 {\n  font-size: 48px;\n  font-weight: 600;\n  line-height: 1.05;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 16px;\n}\n.vercel-hero p {\n  font-size: 20px;\n  font-weight: 400;\n  line-height: 1.80;\n  color: var(--geist-secondary);\n  margin: 0 auto 28px;\n}\n\n/* Workflow Pipeline (Develop -> Preview -> Ship) */\n.workflow-pipeline {\n  display: grid;\n  grid-template-columns: repeat(3, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 768px) {\n  .workflow-pipeline { grid-template-columns: 1fr; }\n}\n.workflow-step {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px 22px;\n  transition: box-shadow 0.2s;\n}\n.workflow-step:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n.step-mono-label {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  margin-bottom: 8px;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n.step-title {\n  font-size: 20px;\n  font-weight: 600;\n  letter-spacing: -0.96px;\n  color: var(--geist-foreground);\n  margin-bottom: 6px;\n}\n.step-desc {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n\n/* Metric Cards (Section 4 Spec) */\n.metric-grid {\n  display: grid;\n  grid-template-columns: repeat(4, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 900px) {\n  .metric-grid { grid-template-columns: repeat(2, 1fr); }\n}\n.metric-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n}\n.metric-number {\n  font-size: 40px;\n  font-weight: 600;\n  line-height: 1.0;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin-bottom: 8px;\n  font-feature-settings: \"tnum\" 1;\n}\n.metric-label {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.4;\n}\n\n/* VAD 专栏 Banner (Ship Red & Vercel Clean) */\n.vad-showcase {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-xl);\n  padding: 32px;\n  margin-bottom: 48px;\n  position: relative;\n}\n.vad-header-row {\n  display: flex;\n  align-items: baseline;\n  justify-content: space-between;\n  flex-wrap: wrap;\n  gap: 12px;\n  margin-bottom: 12px;\n}\n.vad-header-row h2 {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  color: var(--geist-foreground);\n  margin: 0;\n}\n.vad-pillars-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));\n  gap: 14px;\n  margin-top: 24px;\n}\n.vad-pillar-item {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 14px 16px;\n}\n.vad-pillar-title {\n  font-size: 14px;\n  font-weight: 600;\n  color: var(--ship-red);\n  margin-bottom: 4px;\n}\n.vad-pillar-text {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n.vad-filter-bar {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  margin: 24px 0 16px;\n  padding: 12px 16px;\n  background: var(--geist-surface-tint);\n  border-radius: var(--radius-md);\n  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);\n}\n.vad-filter-btn {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  font-weight: 500;\n  padding: 6px 14px;\n  border-radius: 9999px;\n  border: none;\n  background: transparent;\n  color: var(--geist-secondary);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.vad-filter-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0,0,0,0.05);\n}\n.vad-filter-btn.active {\n  background: #171717;\n  color: #ffffff;\n}\n.vad-search-input {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  padding: 7px 12px;\n  border-radius: 6px;\n  border: 1px solid var(--geist-border);\n  background: #ffffff;\n  color: var(--geist-foreground);\n  width: 280px;\n  outline: none;\n  transition: border-color 0.15s, box-shadow 0.15s;\n}\n.vad-search-input:focus {\n  border-color: #0a72ef;\n  box-shadow: 0 0 0 2px rgba(10, 114, 239, 0.2);\n}\n\n/* 控制栏：搜索、视图、筛选 */\n.control-bar {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  margin-bottom: 24px;\n  flex-wrap: wrap;\n}\n.search-input-wrap {\n  position: relative;\n  flex: 1;\n  max-width: 480px;\n}\n.search-input {\n  width: 100%;\n  height: 40px;\n  padding: 0 38px 0 14px;\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  color: var(--geist-foreground);\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  outline: none;\n  transition: box-shadow 0.15s;\n}\n.search-input:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n.search-kbd {\n  position: absolute;\n  right: 12px;\n  top: 50%;\n  transform: translateY(-50%);\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  color: var(--geist-quaternary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n\n.view-switcher {\n  display: flex;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  background: var(--geist-background);\n  padding: 2px;\n}\n.view-btn {\n  background: transparent;\n  border: none;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-tertiary);\n  padding: 6px 12px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n  transition: color 0.15s, background 0.15s;\n}\n.view-btn.active {\n  background: var(--geist-surface-tint);\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 筛选芯片行 (Filter Pill Strip) */\n.filter-group-strip {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n  margin-bottom: 28px;\n  padding: 16px 20px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-lg);\n}\n.filter-row {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  flex-wrap: wrap;\n}\n.filter-label-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  min-width: 68px;\n}\n.pill-badge {\n  background: var(--geist-background);\n  color: var(--geist-secondary);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 3px 12px;\n  border-radius: var(--radius-pill);\n  font-size: 12px;\n  font-weight: 500;\n  cursor: pointer;\n  transition: all 0.15s;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n}\n.pill-badge:hover {\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border-hover);\n}\n.pill-badge.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  font-weight: 600;\n  box-shadow: none;\n}\n.pill-badge.active-blue {\n  background: var(--develop-blue);\n  color: #ffffff;\n  box-shadow: none;\n}\n.pill-badge.active-red {\n  background: var(--ship-red);\n  color: #ffffff;\n  box-shadow: none;\n}\n\n/* Bento Grid Cards (Section 4 & 6 Spec) */\n.card-grid-bento {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n  gap: 16px;\n}\n.vercel-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  transition: box-shadow 0.2s, transform 0.2s;\n  text-decoration: none;\n  color: inherit;\n  overflow: hidden;\n  min-width: 0;\n  word-break: break-word;\n}\n.vercel-card:hover {\n  box-shadow: var(--shadow-card-hover);\n  transform: translateY(-2px);\n}\n.card-top {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  margin-bottom: 12px;\n  gap: 8px;\n}\n.card-tag-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  letter-spacing: 0.5px;\n}\n.status-pill-badge {\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 500;\n  flex-shrink: 0;\n}\n.pub-accepted { background: #ebfdf2; color: #027a48; }\n.pub-workshop { background: #eff8ff; color: #175cd3; }\n.pub-submitted { background: #fff8e6; color: #b54708; }\n.pub-preprint { background: #f2f4f7; color: #475467; }\n.pub-other { background: #f9f5ff; color: #6941c6; }\n\n[data-theme=\"dark\"] .pub-accepted { background: rgba(2, 122, 72, 0.2); color: #32d583; }\n[data-theme=\"dark\"] .pub-workshop { background: rgba(23, 92, 211, 0.2); color: #84caff; }\n[data-theme=\"dark\"] .pub-submitted { background: rgba(181, 71, 8, 0.2); color: #fec84b; }\n[data-theme=\"dark\"] .pub-preprint { background: rgba(71, 84, 103, 0.2); color: #98a2b3; }\n[data-theme=\"dark\"] .pub-other { background: rgba(105, 65, 198, 0.2); color: #d6bbfb; }\n\n/* 必读标杆徽章 (Vercel Amber Accent) */\n.milestone-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 3px;\n  padding: 2px 7px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 600;\n  white-space: nowrap;\n  flex-shrink: 0;\n  transition: all 0.15s ease;\n}\n.milestone-badge.ms-idea, .milestone-badge:not([class*=\"ms-\"]) {\n  color: #b54708;\n  background: #fff8e6;\n  border: 1px solid rgba(247, 144, 9, 0.35);\n  box-shadow: 0 1px 2px rgba(181, 71, 8, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-idea, [data-theme=\"dark\"] .milestone-badge:not([class*=\"ms-\"]) {\n  color: #fec84b;\n  background: rgba(181, 71, 8, 0.22);\n  border-color: rgba(254, 200, 75, 0.35);\n}\n.milestone-badge.ms-writing {\n  color: #6941c6;\n  background: #f9f5ff;\n  border: 1px solid rgba(105, 65, 198, 0.3);\n  box-shadow: 0 1px 2px rgba(105, 65, 198, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-writing {\n  color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.22);\n  border-color: rgba(214, 187, 251, 0.35);\n}\n.milestone-badge.ms-value {\n  color: #027a48;\n  background: #ebfdf2;\n  border: 1px solid rgba(2, 122, 72, 0.3);\n  box-shadow: 0 1px 2px rgba(2, 122, 72, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-value {\n  color: #32d583;\n  background: rgba(2, 122, 72, 0.22);\n  border-color: rgba(50, 213, 131, 0.35);\n}\n\n/* 论文正文图表与插图卡片样式 (Geist Design) */\n.paper-figure, .article-body figure {\n  margin: 32px auto;\n  text-align: center;\n  max-width: 100%;\n}\n.paper-figure img, .article-body img {\n  max-width: 96%;\n  height: auto;\n  border-radius: var(--radius-md);\n  border: 1px solid var(--geist-border);\n  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);\n  background: #ffffff;\n  transition: transform 0.2s ease, box-shadow 0.2s ease;\n  display: block;\n  margin: 0 auto;\n}\n.paper-figure img:hover, .article-body img:hover {\n  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);\n}\n.paper-figure figcaption, .article-body figcaption {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  margin-top: 10px;\n  line-height: 1.6;\n  font-style: italic;\n  max-width: 850px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n/* VAD 视图切换器 View Switcher */\n.vad-view-switcher {\n  display: inline-flex;\n  padding: 3px;\n  background: var(--geist-secondary-bg);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  margin-bottom: 20px;\n  gap: 2px;\n}\n.view-switch-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 6px 14px;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  border-radius: 6px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.view-switch-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0, 0, 0, 0.04);\n}\n[data-theme=\"dark\"] .view-switch-btn:hover {\n  background: rgba(255, 255, 255, 0.06);\n}\n.view-switch-btn.active {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  font-weight: 600;\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n/* 关系图谱 Graph View Styles */\n.graph-container {\n  position: relative;\n  width: 100%;\n  height: 720px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: var(--radius-lg);\n  overflow: hidden;\n  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);\n  margin-bottom: 40px;\n}\n.graph-toolbar {\n  position: absolute;\n  top: 14px;\n  left: 14px;\n  right: 14px;\n  z-index: 10;\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  padding: 8px 14px;\n  border-radius: 8px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  flex-wrap: wrap;\n  gap: 8px;\n}\n.graph-tool-title {\n  font-size: 13px;\n  font-weight: 700;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  color: var(--geist-foreground);\n}\n.graph-filter-group {\n  display: flex;\n  gap: 6px;\n  align-items: center;\n  flex-wrap: wrap;\n}\n.graph-chip {\n  font-size: 11px;\n  padding: 3px 8px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.graph-chip:hover { background: var(--geist-secondary-bg); }\n.graph-chip.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-color: var(--geist-foreground);\n}\n.graph-search-input {\n  padding: 3px 8px;\n  font-size: 11px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  outline: none;\n  width: 150px;\n}\n#vad-graph-svg {\n  width: 100%;\n  height: 100%;\n  cursor: grab;\n}\n#vad-graph-svg:active { cursor: grabbing; }\n.graph-legend {\n  position: absolute;\n  bottom: 14px;\n  left: 14px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  padding: 10px 14px;\n  font-size: 11px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  z-index: 10;\n  line-height: 1.6;\n  pointer-events: none;\n}\n.graph-legend-row { display: flex; align-items: center; gap: 8px; }\n.graph-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }\n.graph-info-drawer {\n  position: absolute;\n  top: 66px;\n  right: 14px;\n  width: 310px;\n  max-height: 620px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  box-shadow: 0 8px 30px rgba(0,0,0,0.12);\n  z-index: 10;\n  padding: 16px;\n  overflow-y: auto;\n  display: none;\n  backdrop-filter: blur(10px);\n  transition: transform 0.2s ease, opacity 0.2s ease;\n}\n.graph-drawer-close {\n  position: absolute;\n  top: 10px;\n  right: 12px;\n  cursor: pointer;\n  font-size: 16px;\n  color: var(--geist-tertiary);\n}\n.graph-drawer-badge {\n  display: inline-block;\n  padding: 2px 6px;\n  border-radius: 4px;\n  font-size: 10px;\n  font-weight: 600;\n  margin-bottom: 6px;\n}\n.graph-drawer-title {\n  font-size: 13px;\n  font-weight: 700;\n  line-height: 1.4;\n  margin-bottom: 8px;\n  color: var(--geist-foreground);\n}\n.graph-drawer-meta {\n  font-size: 11px;\n  color: var(--geist-secondary);\n  margin-bottom: 12px;\n}\n.graph-drawer-core {\n  font-size: 12px;\n  line-height: 1.6;\n  color: var(--geist-foreground);\n  background: var(--geist-secondary-bg);\n  padding: 8px 10px;\n  border-radius: 6px;\n  margin-bottom: 12px;\n  border: 1px solid var(--geist-border);\n}\n.graph-drawer-link {\n  display: block;\n  text-align: center;\n  padding: 7px 12px;\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-radius: 6px;\n  font-size: 12px;\n  font-weight: 600;\n  text-decoration: none;\n  transition: opacity 0.15s ease;\n  margin-bottom: 6px;\n}\n.graph-drawer-link:hover { opacity: 0.85; }\n.graph-drawer-pdf-link {\n  display: block;\n  text-align: center;\n  padding: 6px 12px;\n  background: var(--geist-secondary-bg);\n  color: var(--geist-foreground);\n  border: 1px solid var(--geist-border);\n  border-radius: 6px;\n  font-size: 11px;\n  font-weight: 500;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.graph-drawer-pdf-link:hover { background: var(--geist-border); }\n.node-circle {\n  cursor: pointer;\n  transition: r 0.2s, stroke-width 0.2s;\n}\n.node-label {\n  font-size: 10px;\n  font-weight: 600;\n  fill: var(--geist-foreground);\n  pointer-events: none;\n  text-shadow: 0 1px 2px var(--geist-background);\n}\n.link-line {\n  stroke: var(--geist-border);\n  stroke-opacity: 0.6;\n  stroke-width: 1.2;\n  transition: stroke 0.2s, stroke-width 0.2s, stroke-opacity 0.2s;\n}\n.link-label {\n  font-size: 9px;\n  fill: var(--geist-tertiary);\n  pointer-events: none;\n  text-anchor: middle;\n}\n\n/* 引用框与警示框 Alerts */\n.callout-alert {\n  margin: 20px 0;\n  padding: 14px 18px;\n  border-radius: var(--radius-md);\n  transition: all 0.15s ease;\n}\n.callout-important, .callout-idea {\n  border-left: 4px solid #b54708;\n  background: rgba(181, 71, 8, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(247, 144, 9, 0.3);\n}\n[data-theme=\"dark\"] .callout-important, [data-theme=\"dark\"] .callout-idea {\n  border-left-color: #fec84b;\n  background: rgba(181, 71, 8, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(254, 200, 75, 0.25);\n}\n.callout-writing {\n  border-left: 4px solid #6941c6;\n  background: rgba(105, 65, 198, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(105, 65, 198, 0.3);\n}\n[data-theme=\"dark\"] .callout-writing {\n  border-left-color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(214, 187, 251, 0.25);\n}\n.callout-value {\n  border-left: 4px solid #027a48;\n  background: rgba(2, 122, 72, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(2, 122, 72, 0.3);\n}\n[data-theme=\"dark\"] .callout-value {\n  border-left-color: #32d583;\n  background: rgba(2, 122, 72, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(50, 213, 131, 0.25);\n}\n\n.card-title {\n  font-size: 16.5px;\n  font-weight: 600;\n  line-height: 1.42;\n  letter-spacing: -0.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 10px;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n  hyphens: auto;\n}\n.card-title a {\n  color: var(--geist-foreground);\n  text-decoration: none;\n  display: inline;\n  transition: color 0.15s ease;\n}\n.card-title a:hover {\n  color: var(--develop-blue);\n  text-decoration: none;\n}\n.card-id-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-quaternary);\n  margin-right: 5px;\n}\n.card-meta-row {\n  display: flex;\n  gap: 6px;\n  flex-wrap: wrap;\n  margin-bottom: 12px;\n}\n.meta-token {\n  font-size: 12px;\n  color: var(--geist-tertiary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-ring);\n  padding: 2px 7px;\n  border-radius: var(--radius-sm);\n  white-space: nowrap;\n}\n.card-body-text {\n  font-size: 13.5px;\n  color: var(--geist-secondary);\n  line-height: 1.6;\n  margin-bottom: 16px;\n  flex-grow: 1;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n}\n.card-body-text strong {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n.card-footer {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 14px;\n}\n.card-link-action {\n  font-size: 13.5px;\n  font-weight: 500;\n  color: var(--link-blue);\n  display: inline-flex;\n  align-items: center;\n  gap: 4px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.card-link-action:hover {\n  opacity: 0.85;\n  transform: translateX(2px);\n}\na.meta-token {\n  transition: all 0.15s ease;\n  cursor: pointer;\n  text-decoration: none;\n}\na.meta-token:hover {\n  background: var(--geist-selection);\n  color: var(--geist-foreground);\n  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);\n}\n\n/* 紧凑列表视图 (List View) */\n.card-list-view {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n}\n.list-row-item {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-md);\n  padding: 12px 18px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  transition: box-shadow 0.15s;\n}\n.list-row-item:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n\n/* 阅读详情页 (Report Detail) */\n.reading-container {\n  display: grid;\n  grid-template-columns: minmax(0, 1fr) 260px;\n  gap: 40px;\n  align-items: start;\n}\n@media (max-width: 960px) {\n  .reading-container { grid-template-columns: 1fr; }\n  .reading-sidebar { display: none; }\n}\n\n.report-header-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 28px 32px;\n  margin-bottom: 28px;\n}\n.crumb-bar {\n  font-size: 13px;\n  color: var(--geist-tertiary);\n  margin-bottom: 10px;\n}\n.report-title {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  margin: 0 0 16px;\n  color: var(--geist-foreground);\n}\n.report-action-buttons {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  flex-wrap: wrap;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 16px;\n  margin-top: 16px;\n}\n\n.article-body {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 36px 42px 80px;\n  font-size: 16px;\n  line-height: 1.75;\n  color: var(--geist-foreground);\n}\n.article-body h1, .article-body h2, .article-body h3 {\n  color: var(--geist-foreground);\n  scroll-margin-top: 80px;\n}\n.article-body h1 { font-size: 28px; font-weight: 600; letter-spacing: -1.28px; border-bottom: 1px solid var(--geist-border); padding-bottom: 8px; margin-top: 32px; }\n.article-body h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.96px; border-bottom: 1px solid var(--geist-border); padding-bottom: 6px; margin-top: 36px; }\n.article-body h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.32px; margin-top: 26px; }\n.article-body table {\n  width: 100%;\n  border-collapse: collapse;\n  margin: 24px 0;\n  font-size: 14px;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  overflow: hidden;\n}\n.article-body th, .article-body td {\n  padding: 10px 14px;\n  text-align: left;\n  border-bottom: 1px solid var(--geist-border);\n}\n.article-body th {\n  background: var(--geist-surface-tint);\n  font-weight: 600;\n  color: var(--geist-foreground);\n}\n.article-body blockquote {\n  border-left: 2px solid var(--geist-foreground);\n  margin: 20px 0;\n  padding: 8px 18px;\n  color: var(--geist-secondary);\n  font-style: normal;\n}\n.article-body code {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13.5px;\n  box-shadow: var(--shadow-ring);\n  background: var(--geist-surface-tint);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n.article-body pre {\n  position: relative;\n  background: #000000;\n  color: #ededed;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 18px;\n  margin: 24px 0;\n  overflow-x: auto;\n}\n.article-body pre code {\n  background: transparent;\n  box-shadow: none;\n  padding: 0;\n  color: inherit;\n  font-size: 13px;\n}\n.copy-code-btn {\n  position: absolute;\n  top: 8px;\n  right: 10px;\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  background: #171717;\n  color: #ffffff;\n  border: 1px solid #333333;\n  padding: 3px 8px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n}\n\n/* 侧边大纲 (TOC) */\n.reading-sidebar {\n  position: sticky;\n  top: 80px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  max-height: calc(100vh - 100px);\n  overflow-y: auto;\n}\n.sidebar-toc-title {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: var(--geist-quaternary);\n  margin-bottom: 12px;\n}\n.reading-sidebar ul {\n  list-style: none;\n  padding-left: 0;\n  margin: 0;\n  font-size: 13px;\n}\n.reading-sidebar li {\n  margin: 6px 0;\n}\n.reading-sidebar ul ul {\n  padding-left: 14px;\n}\n.reading-sidebar a {\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.reading-sidebar a:hover, .reading-sidebar a.active {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 后台管理 (/admin) */\n.admin-card-container {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 32px;\n  margin-bottom: 32px;\n}\n.form-row-2 {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 16px;\n  margin-bottom: 16px;\n}\n@media (max-width: 600px) {\n  .form-row-2 { grid-template-columns: 1fr; }\n}\n.form-field {\n  display: flex;\n  flex-direction: column;\n  gap: 6px;\n  margin-bottom: 16px;\n}\n.form-field label {\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-foreground);\n}\n.form-field input, .form-field select, .form-field textarea {\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  padding: 9px 12px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  color: var(--geist-foreground);\n  outline: none;\n}\n.form-field input:focus, .form-field select:focus, .form-field textarea:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n\n/* 语法高亮 (Console Blue / Purple / Pink) */\n.codehilite .k, .codehilite .kd, .codehilite .kn { color: #eb367f; font-weight: 500; }\n.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #0070f3; }\n.codehilite .nf, .codehilite .na { color: #7928ca; font-weight: 500; }\n.codehilite .c, .codehilite .c1 { color: #666666; font-style: italic; }\n.codehilite .mi, .codehilite .mf { color: #ff5b4f; }\n\n</style>\n\n</head>\n<body>\n\n    <nav class=\"vercel-nav\">\n      <div class=\"nav-brand\">\n        <a href=\"/\" style=\"display:flex;align-items:center;gap:10px;text-decoration:none\">\n          <svg class=\"vercel-triangle\" viewBox=\"0 0 76 65\" fill=\"none\">\n            <path d=\"M37.5274 0L75.0548 65H0L37.5274 0Z\" fill=\"currentColor\"/>\n          </svg>\n          <span class=\"nav-title\">Agent Harness KB</span>\n        </a>\n        <span class=\"nav-badge-pill\">Geist 2.0</span>\n      </div>\n\n      <div class=\"nav-links\">\n        <a class=\"nav-link \" href=\"/\">全景总览</a>\n        <a class=\"nav-link \" href=\"/vad\" style=\"color:var(--ship-red)\">🎯 VAD 专栏 (144)</a>\n        <a class=\"nav-link\" href=\"https://m0rtzz.github.io/paper-notes/\" target=\"_blank\" rel=\"noopener\">顶会 669 篇 ↗</a>\n        <a class=\"nav-link\" href=\"/download/all\">整库打包</a>\n        \n      </div>\n\n      <div class=\"nav-actions\">\n        \n        <button class=\"theme-toggle-btn\" id=\"theme-toggle-btn\" onclick=\"toggleTheme()\" title=\"切换亮暗主题\">🌙</button>\n      </div>\n    </nav>\n    \n<main class=\"vercel-container\">\n\n        <div class=\"report-header-card\">\n          <div class=\"crumb-bar\"><a href=\"/\">Home</a> / <b>fulltext.txt</b></div>\n          <h1 class=\"report-title\">fulltext.txt</h1>\n          <div class=\"report-action-buttons\">\n            <a class=\"btn-primary-dark\" href=\"?dl=1\">Download Text</a>\n          </div>\n        </div>\n        <article class=\"article-body\"><pre><code>Preprint version\n\nC ACHE E NGINEERING FOR AGENTS\nTianyu Fu∗ 1 , Ruoxi Wang∗1 , Zihan Min∗1 , Zhongqi Ren1 , Zhihao Li1 ,\nTengxuan Liu1 , Shengxu Mu1 , Hanling Zhang2 , Yu Wang†1\n1\n\n2\n\nTsinghua University\n\nThe Chinese University of Hong Kong\n\narXiv:2610.28577v1 [cs.CL] 20 Oct 2026\n\nA BSTRACT\nLarge Language Model (LLM) agents can handle increasingly complex tasks, navigating long trajectories of observations and actions. As these trajectories grow,\nkey-value (KV) cache I/O and storage become the dominant cost. Trajectories\ncan also exceed the LLM’s maximum context length, requiring control over active cache growth. Prior work uses context engineering to reduce cache size by\ntrimming or summarizing history. However, modifying the trajectory prefix invalidates subsequent cached states and triggers costly re-prefilling of retained context.\nTask accuracy can also suffer when too little context is retained to limit re-prefill\ncosts. We propose cache engineering as a new scheme. It allows agents to directly\ncontrol their active KV cache without modifying the trajectory or re-prefilling retained context. Specifically, agents can proactively use drop to exclude selected\ncache from future attention and repos to adjust retained keys’ position encodings. We formalize these cache operations and identify history dependence as a\nserving challenge: identical token sequences can yield different cache states under different cache operation sequences, making prefix matching insufficient for\ncorrect cache reuse. Thus, we co-design the AKV serving engine. It provides a\nstateless interface compatible with existing serving APIs, while internally managing stateful cache reuse, eviction, and restoration. Experiments show that a toolresponse rolling-drop cache policy improves average benchmark scores by 1.7\npoints and reduces average cost by 27.7%, compared with conventional thresholdtriggered summarization. With AKV, it achieves up to 1.2× the output throughput and a 1.5× speedup in P95 request latency. Recursive self-improvement of\ncache policies further reduces cost by 7.1% over expert design. Our code is at\nhttps://github.com/thu-nics/AKV.\n\n1\n\nI NTRODUCTION\n\nLarge Language Model (LLM) agents are capable of increasingly long-horizon tasks. Agents are\ngenerally composed of an LLM for reasoning and tool calling, and a harness that orchestrates tool\nexecution and context. Through repeated reasoning, tool use, and environment interactions, they can\ncarry out complex work spanning hundreds of rounds (Ye et al., 2025; Liu et al., 2025b).\nAs agent trajectories grow longer, Key-Value (KV) cache growth poses challenges to both inference\ncost and task accuracy. In terms of cost, retaining and repeatedly accessing accumulated KV caches\nincur substantial storage and I/O overhead (Wu et al., 2026; Anthropic, 2026). As shown in Figure 13, KV cache reads take up 82.4% of the total API cost. In terms of task accuracy, agents can\nsuffer severe degradation if either the number of attended KV states or their positional range exceeds\nwhat LLM handles reliably (Hsieh et al., 2024; Chen et al., 2026b; Zhou et al., 2025). Therefore, it\nrequires delicate control over the active KV cache for efficient and reliable agent execution.\nPrior work reduces the growing cache via context engineering, typically by trimming or summarizing historical messages. While older messages are often less useful, editing them changes the trajectory prefix, invalidates subsequent KV states, and triggers re-prefill. The earlier the edit, the more\nretained trajectory suffix that must be re-prefilled. Common harnesses therefore defer reductions\nuntil an active context length threshold is reached, then trim or summarize most of the trajectory and\n∗\n\nEqual contribution.\n\n†\n\nCorresponding author: Yu Wang (yu-wang@tsinghua.edu.cn).\n\n1\n\n\fPreprint version\n\nCached irrelevant search history\n\nCached useful search history\n\n… café hours, tickets, bus routes …\n\n“Opened in 1998”\n\nQ: When did the museum open?\n\nAgent\n\nServing system\n\nMessages\n\nKV operation\n\nKeep all text\n\nFull-context\n\nComputation\n\nReuse all KV\n\nNew Q\nNo cache recompute\n\nQ\n\nRecompute cache\n\nCannot reuse KV\n\nDelete context prefix\n\nContext\nEngineering\n\nQ\n\nConditioned on\ngrey\nNew Q\nConditioned on\ngreen\n\n+\nDrop irrelevant KV\n\nDirect KV cache control\n\nCache\nEngineering\n\nNew user question\n\nReuse KV\n\nNew Q\nNo cache recompute\n\nQ\n\nConditioned on\ngreen that is\nconditioned on grey\n\nFigure 1: Full-context inference, context engineering, and cache engineering. Full-context inference\nreuses all historical KV. Context engineering removes irrelevant text and recomputes the retained\nhistory. Cache engineering keeps the text history but drops selected KV entries, reusing retained\nstates without recomputation. Nested color blocks illustrate how retained KV can still carry information from dropped history.\nretain only a few recent rounds to keep re-prefill short (Pi, 2026; OpenAI, 2026). Such aggressive\nreductions risk losing useful information from intermediate rounds, exposing a dilemma between\nre-prefill cost and task accuracy.\nIn this paper, we introduce cache engineering, a new scheme for agents to directly control their\nactive KV cache. As shown in Figure 1, instead of modifying the text trajectory, it excludes only\nselected KV entries from future attention, and reuses all retained KV states without re-prefill. This\nallows agents to incrementally drop older KV entries while retaining more suffix KV within a given\ncost budget. To support this control, alongside the usual append operation that adds KV states for\nnew tokens, we introduce two additional cache operations. Drop removes selected KV entries from\nfuture attention, and repos adjusts the positions encoded in retained keys. Throughout execution,\nthe LLM and harness choose when and how to apply these operations, repeatedly interleaving them\nwith append to shape the active cache. This programmable control also enables agents to search,\nevaluate, and refine cache engineering strategies through recursive self-improvement (RSI).\nHowever, the history-dependent nature of cache engineering challenges current LLM serving systems. With standard KV caching, the token prefix fully determines the cached states (Kwon et al.,\n2023; Zheng et al., 2024). In contrast, the same token prefix and retained positions can result in\ndifferent cache states under different cache operation histories. As shown in Figure 5, trajectories\n① and ② both retain KV entries for B and C, but C’s KV is computed with attention to A only in\n①, due to the different ordering of drop and append operations. The serving system must therefore\naccount for both token and cache operation histories to correctly track or reuse cache states.\nThus, we co-design AKV, a user-friendly and efficient serving system for cache engineering. It provides a stateless interface compatible with existing API-based serving, while handling the complexity of stateful cache management internally. Agents simply submit messages as usual, accompanied\nby cache operation instructions, without tracking which KV states remain resident on the server. The\nsystem uses an extended radix tree for correct reuse and timely eviction of history-dependent cache\nstates, while segment-batch attention efficiently reconstructs missing states in a single prefill pass.\nAKV turns the theoretical efficiency potential of cache engineering into lower wall-clock latency\nand higher throughput for real-world agent workloads.\n• Cache engineering formulation. We formalize cache engineering through explicit cache\noperations and their trajectories, providing a clear and deterministic description of historydependent cache states. This formulation also provides a programmable interface for agents\nto define and refine their own cache engineering strategies.\n• Serving system for cache engineering. We propose the first serving system that allows\nagents to directly control their caches, which were previously managed solely by the system. We co-design a stateless interface, an extended radix tree, and segment-batch attention\nto support efficient cache reuse, eviction, and restoration.\n• Improving efficiency and benchmark performance. Across three LLMs and four agent\nbenchmarks, a simple tool-response rolling-drop cache policy reduces average cost by\n2\n\n\fPreprint version\n\n27.7% and improves average benchmark scores by 1.7 points, compared with conventional\nthreshold-triggered summarization. With AKV server, this translates to 1.18× the output\nthroughput and a 1.51× speedup in P95 request latency. An RSI-based policy additionally\nreduces cost by 7.1% on held-out tasks.\n\n2\n\nR ELATED W ORK\n\nAgent context engineering. At the text level, context engineering summarizes or trims interaction\nhistories to reduce cost and enable agents to work beyond the LLM’s context window. Existing\nmethods trigger summarization through heuristics (Wu et al., 2025) or agent decisions (Ye et al.,\n2025; Sun et al., 2025). Further work improves summary quality through reinforcement learning (Lu\net al., 2025) or by optimizing compression guidelines (Kang et al., 2025). To avoid the cost and\ncomplexity of summarization, trimming methods (Lindenbauer et al., 2025; Zhang et al., 2026)\ndirectly remove less relevant context. However, editing earlier context requires re-prefilling the\nretained suffix, creating a dilemma between re-prefill cost and information retention.\nKV cache compression, eviction, and reuse. At the cache level, prior work reduces cache size or\napproximately reuses existing states to lower storage, access, and computation costs. Compression\nmethods use low-rank representations (Liu et al., 2024a; Wang et al., 2024a), quantization (Liu et al.,\n2024b; 2026b), or aggregation (Fu et al., 2025b; Wang et al., 2024b) to represent cached entries more\ncompactly. Eviction methods typically rely on low-level signals such as token positions (Xiao et al.,\n2024) or attention-based importance (Zhang et al., 2023; Li et al., 2024; Fu et al., 2025a; Yang\net al., 2026) to remove less useful cache entries. Reuse methods adapt cached states to different\npositions or context prefixes through position encoding adjustments (Gao et al., 2024; Ma et al.,\n2026; Ordonez &amp; Parnell, 2026) or partial recomputation (Wang et al., 2025). Our work focuses on\neviction and reuse, enabling high-level eviction decisions by agents and harnesses, while providing\na practical serving engine for efficient cross-request reuse and isolation. We discuss concurrent\nagent-oriented eviction work in Appendix A.5.\nKV cache management in serving systems. Beyond algorithmic designs, previous works also explore system optimizations for efficient cache storage, sharing, and request scheduling. Existing\nsystems use prefix caching to share KV states across requests with common prefixes while preserving equivalence to full prefill (Zheng et al., 2024; Ye et al., 2024). For agent workloads, recent\nsystems batch context edits to reduce cache invalidation (Xu et al., 2026) or overlap re-prefill with\nongoing execution to hide its latency (Pan et al., 2026). For cache engineering, it additionally requires tracking cache operation histories, since identical token prefixes can produce different states\nunder different operations.\n\n3\n\nC ACHE E NGINEERING\n\nCache engineering lets agents directly control their active KV cache without rewriting the trajectory\nor re-prefilling retained context. We introduce basic concepts in Section 3.1 and design motivations\nin Section 3.2, then formalize cache operations and their trajectories in Sections 3.3 and 3.4.\n3.1\n\nP RELIMINARIES\n\nAn autoregressive LLM predicts the next token conditioned on the preceding token sequence x1:t :\npθ (xt+1 | x1:t ).\n\n(1)\n\nModern LLM serving uses KV caching to avoid recomputing earlier tokens’ states. The next-token\nprediction is then conditioned on the current token xt and the preceding tokens’ cache:\npθ (xt+1 | xt , C1:t−1 ),\n\n(2)\n\nwhere C1:t−1 denotes the KV states computed from tokens x1:t−1 .\nAn agent’s trajectory is the ordered text history used for the following model computation, including its prompt, assistant messages, and tool responses. Formally, the trajectory is a logical token\nsequence x1:t , and t is its logical token length.\n3\n\n\fPreprint version\n\n10−4\n10−5\n10−6\n0%\n\n20%\n\n40%\n\n60%\n\n80%\n\n100%\n\nRelative token position\n\nFigure 2: Attention over history. Per-token attention to assistant and tool responses, averaged over 10 BCP requests.\n\n66\n64\n62\n60\n58\n56\n54\n52\n50\n48\n46\n\nK=12\n\nBest so far\nMeets baseline accuracy\nBelow baseline accuracy\n\nK=4\n72k\nStandard\n\nK=1\nStandard\nText engineering\nAKV\nMean ± std\n$0.06\n\n$0.08\n\n$0.10\n\n60k\n48k\n$0.12\n\n$0.14\n\nCost per case (USD)\n\nFigure 3: GPT-OSS-120B accuracy and cost on 100 BCP\ntasks. Labels indicate summary\nthresholds (tokens) or AKV’s\nretained tool rounds.\n\nPer-task cost (cents)\n\nTool response\n\nAccuracy (%)\n\nAttention per token\n\nAssistant response\n\n5.5\n\nStandard baseline\n\n5.0\n\nHuman expert design\n\n4.5\n\n15.6% lower\n\n17.8% lower\n\n4.0\n0\n\n2\n\n4\n\n6\n\n8\n\nSearch iteration\n\nFigure 4:\nRecursive selfimprovement on cache engineering policy, evaluated\non the BCP benchmark with\nMiniMax-M2.7 LLM.\n\nIn cache engineering, the cache size need not equal the logical token length. We therefore define the\nactive cache C as the KV cache states available to subsequent attention. The corresponding token\nsequence is the active context, whose length equals the number of token entries in C. Note that\nactive refers to participation in attention at the algorithmic level, not physical cache residency in the\nserving engine. A cache entry’s position encoding index can also be adjusted independently of its\ntoken’s logical index in the trajectory.\nContext engineering modifies the logical token sequence through trimming or summarization. In\ncontrast, cache engineering directly modifies the active cache through cache operations, while keeping the logical token sequence unchanged.\n3.2\n\nD ESIGN M OTIVATION\n\nThe design of cache engineering stems from our thinking about three key questions: why direct\ncache modification is needed, which parts of the cache to retain, and how to manage its encoding\npositions. We discuss the motivations and empirical evidence guiding our design decisions below.\nWhy modify the cache directly. Cache engineering alleviates the dilemma between re-prefill cost\nand task accuracy in context engineering. We evaluate GPT-OSS-120B on the first 100 BCP tasks,\nwith four trials per task and at most 100 agent rounds. Trim-based context engineering (retaining only the latest 12 rounds of tool responses) costs 1.85× as much as the full-context baseline.\nSummary-based context engineering (48k threshold) reduces cost by about 7% but lowers accuracy\nby 5 percentage points (Figure 3). In contrast, directly dropping older tool-response cache can reuse\nthe remaining cache, simultaneously improving accuracy and reducing cost (Figure 3). The retained\ncache may also preserve information from dropped history used in its computation (Xiao et al., 2024;\nFu et al., 2026; Zou et al., 2025), as shown in Figure 1.\nWhich parts of the cache to retain. Cache selection should reflect message roles, recency, and\ntask needs, beyond token-level importance heuristics. Figure 2 shows that older tokens receive\nless attention than recent ones, and tool responses receive less attention than assistant messages at\ncomparable relative positions. We therefore use tool-response rolling drop as our primary example,\nretaining cache for all reasoning and recent tool responses while dropping older tool-response cache.\nWe later explore alternative policies, including RSI-based cache engineering.\nHow to manage position encodings. By default, position encoding indices grow with the logical\ntrajectory, even as the cache is reduced. Dropping cache neither changes retained position encodings\nnor resets the next token’s position index, so indices can reach the model’s limit even with a small\ncache. We decouple position encoding indices from logical indices and cache size, using a separate\ncache operation to reposition cached keys with RoPE rotations (Su et al., 2023) without re-prefill.\n3.3\n\nC ACHE O PERATIONS\n\nWe define three basic cache operations for cache engineering: append, drop, and repos, which\ndirectly manipulate cache without rewriting the existing logical token sequence.\n4\n\n\fPreprint version\n\nMessages\n\nA\n\nB\n\nC\n\nKV conditioning\non earlier cache\n\nD\n\n(a) Different cache operation trajectories\n\n+ C\n\nA\n\nB\n\nC\n\n− A\n\n1\nA\n\nB\n\n−\n\nA\n\nB\n\n3\n\nKV dropped\n\nToken node\n\n(b) Different retained cache states\nsame\nretained\ncache\npositions\nB\n\n2\n\nA\n\nB\n1\n\n+ C\n\n−\n\n2\n\n− A\n\n+ C\n\n3\n\nB\n\n+ C\n\n+ C\n\n≠\n\n+ C\n\n(c) Extended radix tree\nD\n\nC\n\nA\n\n=\n\nC\n\nΔ Drop node\n\n≠\n≠\n\nA\n\nC\n\nΔA\n\n1\n\nΔA\n\nC\n\n2\n\nB\n\nC\n\n3\n\nB\n\nD\n\nroot\n\nD\n\nFigure 5: Cache operation trajectories and history-dependent KV states. (a) ① appends C to A and\nB, then drops A’s KV; ② drops A’s KV before appending C; ③ starts from B alone and appends C.\nAll three retain B and C. (b) B’s KV is identical in ① and ②, both conditioned on A, but differs in\n③, where B has no prefix. C’s KV differs in all three: ① is computed with A and B; ② and ③ cannot\nattend to A but use different B caches. (c) The extended radix tree shares the A–B prefix of ① and\n②, then branches according to drop timing, distinguishing the cached states used to generate D.\nAppend. Operation append is the standard cache update in LLM inference. It processes a new\ntoken xt+1 conditioned on the active cache and appends its cache entry Ct+1 :\nC ← [C; Ct+1 ].\n\nappend(xt+1 ) :\n\n(3)\n\nWe represent C as a sequence of KV entries ordered by their logical indices, where [·; ·] denotes\nconcatenation. The token may come from the prompt, a tool response, or model generation. Position\nencoding indices start at zero and advance by one after each append; repos can reset the next index.\nDrop. Operation drop removes selected KV states from subsequent attention, while leaving the\nretained states, their position encodings, and the logical token sequence unchanged (Figure 1):\ndrop(P ) :\n\nC ← C \\ {Ci : i ∈ P },\n\n(4)\n\nwhere P is the set of active logical token indices selected for dropping, and \\ denotes cache removal,\npreserving the order of retained entries. Note that drop does not change the position encoding\nindices used by subsequent append operations.\nRepos. Operation repos updates cached keys’ position encodings in logical token order, and resets\nthe position index for subsequent append operations. With r retained cache entries, their position indices become 0, . . . , r − 1, and the next appended token uses index r. For rotary position\nembeddings (RoPE) (Su et al., 2023), we move a cached key K from position index p to q by\nK ← R(q)R(p)−1 K,\n\n(5)\n\nwhere R(p) is the rotation matrix at position p. Cached values remain unchanged.\nThese operations define the cache visible to attention at the algorithmic level. The serving system\nhandles physical storage, eviction, and reuse of cache separately in Section 4.\n3.4\n\nC ACHE O PERATION S EQUENCE\n\nTo provide a clear and deterministic description of cache operations, we use a cache operation\nsequence:\no1:m = (o1 , . . . , om ),\noj ∈ {append(x), drop(P ), repos}.\n(6)\nHere, m counts operations, x is a token, and P contains the active logical token indices to drop. For\na fixed LLM, this sequence determines the current cache states, starting from an empty cache.\nCache operation sequences are necessary because cache states are history-dependent: tokens and\nretained positions alone do not determine next-token probabilities. For example, in Figure 5, all three\ntrajectories retain B and C, but A’s cache is available when computing both B and C in ①, only B\nin ②, and neither in ③. Thus, C’s cache states are different in all three trajectories. Similarly, repos\nchanges the position encodings used by later append operations, as shown in Figure 8. Correct\ncache reuse and restoration therefore require both token and cache operation histories.\n5\n\n\fPreprint version\n\nStandard\n100\n\nAccuracy (%)\n\n{ \"model\": \"gpt-oss-120b\",\n\"messages\": [\n{\"role\": \"user\", \"content\": \"Search ICLR\"}, ▷ append(m0 )\n{\"role\": \"assistant\", \"content\": \"Searching\"}, ▷ append(m1 )\n{\"role\": \"tool\", \"content\": \"ICLR is...\"}\n▷ append(m2 )\n], \"cache\": {\n\"drop\": {\"1\": [0],\n▷ drop(m0 )\n\"2\": [1]},\n▷ drop(m1 )\n\"reposition\": [2]\n▷ repos\n}}\n\nText engineering\n\nAKV\n\n88% 88% 88%\n\n80\n\n70%\n\n65%\n54%\n\n60\n40\n\n24%\n\n32%\n\n37%\n\n20\n0\n\n0–48k\n\n48–96k\n\n96k+\n\nLogical sequence length\n\nFigure 6: Illustrative AKV request. Right-hand annotations show Figure 7: BCP accuracy by\ncache operations; mi denotes message i.\nlength with GPT-OSS-120B.\n\n4\n\nAKV S ERVING S YSTEM\n\nAKV follows the principle of stateless interface, stateful serving. Agents control the cache used in\nsubsequent attention by specifying cache operations (Section 4.1), while the server handles physical\ncache reuse, eviction, and restoration internally (Section 4.2).\n4.1\n\nS ERVING I NTERFACE\n\nThe serving interface must keep each request’s output distribution independent of physical cache\nresidency and other requests’ cache operations. For example, drop must affect only the issuing\nrequest’s attention, leaving other requests’ output distributions unchanged even when they share the\nsame prefix cache. Each request must also fully describe the cache states it uses, without relying on\nphysical cache retained from previous turns. This allows the server to fully restore missing cache\nstates if memory pressure causes eviction between turns.\nTo meet these requirements, AKV extends the standard LLM serving API to specify both token and\ncache operation histories. As shown in Figure 6, the existing messages field provides the full logical token sequence, while the optional cache field specifies drop and repos operation sequence\nusing an operate-after grammar. Note that all entries in messages implicitly specify append operations. Each key in drop identifies the message index after which to apply the operation; its value\nlists the message indices whose cache is dropped. The reposition field lists the message indices\nafter which to apply repos. Message indices are zero-based, and drop precedes repos when both\noccur at the same message boundary. For multi-round agent workloads, clients extend the message\nand cache operation histories after each round, following the standard LLM serving workflow.\n4.2\n4.2.1\n\nC ACHE S TATE M ANAGEMENT\nD ESIGN O BJECTIVES AND C HALLENGES\n\nAKV aims to preserve three key properties of conventional LLM serving systems: (1) reusing cached\nstates if and only if they are equivalent to the required states, (2) evicting unused cache states without\ncompromising request isolation, and (3) restoring evicted cache states within one prefill pass.\nServing systems face three corresponding challenges in preserving these properties when supporting\ncache engineering: (1) Token prefixes alone no longer determine cache states, so ordinary prefix\nmatching can incorrectly reuse states from different cache operation histories (Figure 5(b)). (2) KV\ncache dropped by one request may still be needed by another, so evicting it without accounting\nfor other requests can cause unnecessary recomputation or violate request isolation. (3) Ordinary\ncausal prefill cannot reproduce cache states resulting from drops and repositions, while replaying\nthe operation history requires multiple forward passes. AKV addresses these three challenges with\nan extended radix tree, drop-aware eviction, and segment-batch attention, respectively.\n4.2.2\n\nD ROP - AWARE C ACHE M ANAGEMENT\n\nReuse with drop nodes. AKV extends radix-tree prefix matching with drop nodes. When a request\ninvokes drop, AKV inserts a drop node ∆ at the trigger point along the request’s path, recording the\nlogical token indices whose cache is dropped. Because drop leaves retained states unchanged but\n6\n\n\fPreprint version\n\n(a) Existing requests\n\n(b) Before reposition\n\n(c) After reposition\n\nRequest 1\n\nKV cache\n\nKV cache\n\nA\n\nB\n\nD\n\nRequest 2\n\nA\n\nB\n♺\n\nB\n\nC\n\nD\n\nA\n\nB\n\nC\n\nD\n\nB\n\nC\n\n0\n\n1\n\n2\n\n2\n\n0\n\n1\n\n2\n\n2\n\n0\n\n1\n\nRadix tree\n\n− A\n\nreposition B, C\n\nC\n\ncopy + reposition\n\nA\n\nRadix tree\n\n0 Position embedding\n0\n\n1\n\nA\n\nB\n\n0\n\nB\nΔA\n\n2\n\n0\n\nC\n\nA\n\n1\n\n1\n\nΔA\nΔA\n\nC\n\n@C\n\n2\n\nreposition node\n\nC\n\nEvictable\n\nB\n2\n\n2\n\nD\n\nD\n\nFigure 8: repos in the KV pool and radix tree. (a) Two requests share A and B; Request 2 drops\nA before appending C. (b) B and C initially occupy positions 1 and 2. (c) repos creates copies at\npositions 0 and 1 by re-encoding K and copying V. The original B remains shared with Request 1,\nwhile the original C becomes evictable. The tree branches at B to distinguish positional versions\nand records a reposition node after C. Labels p denote position p.\naffects subsequent attention computation, this placement preserves prefix sharing while distinguishing later states. Prefix matching on the extended radix tree reuses cache along matched token and\noperation prefixes. In Figure 5(c), trajectories ① and ② share the A–B prefix but keep distinct C\nstates because they drop A at different points, while trajectory ③ follows a separate branch. When\nprocessing D, each trajectory directly reuses its corresponding B and C caches.\nEvict with drop-awareness. AKV uses drop information to reclaim unused cache before requests\nfinish. A cache entry becomes evictable only when no ongoing computation or restoration needs it.\nFor example, in Figure 5, A’s cache can be freed once both requests ① and ② drop it, even as they\ncontinue generating D. Eviction frees the physical storage but leaves the tree node as an empty\nplaceholder, keeping cached descendants accessible through prefix matching. Among evictable\ncache entries, AKV prioritizes evicting dropped cache over cache from completed requests, since\nthe latter is more likely to be reused in the next round.\nRestore with segment-batch attention. AKV uses segment-batch attention to restore missing\ncache states in a single prefill pass. At each layer, queries are split at drop trigger points, and\neach segment attends causally to its own tokens and to active cache from earlier segments. Note\nthat dropped cache is excluded from later segments but remains available to earlier segments that\noriginally used it, as shown in Figure 10. Only attention is segmented, while the FFN processes\nthe full sequence as one batch. This avoids repeating FFN weight reads, a major source of memory\ntraffic, for each segment.\n4.2.3\n\nR EPOSITION - AWARE C ACHE M ANAGEMENT\n\nWhile drop leaves retained cache unchanged, repos efficiently modifies its keys’ position encodings.\nDifferent requests may therefore need the same cache with different position encodings. Restoration\nmust also reproduce the encodings used at each stage of computation.\nReuse with key rotation. AKV reuses cache after repos by copying cached states and rotating\nkeys, without recomputing hidden states. In Figure 8(c), request 2 copies B and C from positions\n1 and 2 to positions 0 and 1, while request 1 continues using the original B. In the radix tree,\nthese copies form a new branch with updated position indices and a reposition node after C. Prefix\nmatching checks both token and operation histories: matching position indices allow direct reuse,\nwhile differing indices require key rotation. Appendix A.1.2 explains why reposition nodes are\nnecessary and details the matching rules and position transformations.\nEvict positional versions independently. AKV evicts each position encoding versions independently, when it is no longer in use by any ongoing computation or restoration. For example, in\nFigure 8(c), the original B remains in use by Request 1, while the original C becomes evictable.\nRestore with temporary KV versions. AKV extends segment-batch attention so each segment uses\nthe position encodings from its original computation. Queries are also split at repos trigger points.\nAt each layer, AKV rotates keys and copies values to create temporary KV versions for segments\nthat require different positions, which we detail in Appendix A.1.1.\n7\n\n\fPreprint version\n\nText engineering\n\n(b)\n\nAKV\n\nC=14\nC=12\n\n40%\n\nC=14\n\n30%\n20%\n10%\n0%\n\nStandard\n\nText engineering\n\n(c)\n\nAKV\n\n50%\n40%\n30%\n20%\n10%\n0%\n\n0\n\n10\n\n20\n\nGPU hours\n\n30\n\nStandard\n\nText engineering\n\nAKV\n\n8\n\n14\n\n50\n\nTotal throughput\n(k tokens/s)\n\nStandard\n\n50%\n\nCumulative pass rate\n\nCumulative pass rate\n\n(a)\n\n40\n30\n20\n10\n0\n\n0\n\n3\n\n6\n\n9\n\nCumulative logical input (M tokens)\n\n12\n\n4\n\n6\n\n10\n\n12\n\n16\n\nConcurrency\n\nFigure 9: Task performance and serving throughput with GPT-OSS-120B on SWE-bench Verified.\n(a) Online evaluation on the first 100 tasks: mean cumulative pass rate versus GPU hours across three\nruns per method, with shaded regions indicating ±1 standard deviation. (b) Cumulative pass rate\nversus cumulative logical input tokens over all 500 tasks. (c) Serving throughput versus concurrency.\n\n5\n\nE XPERIMENT\n\n5.1\n\nS ETUP\n\nBaselines. We compare AKV with two context engineering baselines that summarize accumulated history, following common practice in agent harnesses (Anthropic, n.d.; OpenAI, n.d.). Standard uses a higher, model-specific summarization threshold: 96K tokens for GPT-OSS-120B and\nMiniMax-M2.7, and 192K tokens for MiroThinker-1.7-Mini. Text Engineering uses the same summarization policy with a lower threshold of 48K tokens across all models. For AKV, we use a\ntool-response rolling-drop policy that retains the KV states of the latest 12 tool responses. Its repos\nthreshold matches Standard’s summarization threshold for each model.\nModels and benchmarks. We evaluate AKV across MiniMax-M2.7 (Chen et al., 2026a), GPTOSS-120B (Agarwal et al., 2025), and MiroThinker-1.7-Mini (Team et al., 2026) LLMs. GPT-OSS120B is evaluated with high reasoning effort, while MiniMax-M2.7 and MiroThinker-1.7-Mini are\nevaluated in thinking mode. The benchmarks cover various long-horizon agentic tasks, including\nBrowseComp-Plus (Chen et al., 2025) (BCP), xbench-DeepSearch-2510 (xbench, 2025) (xbenchDS), and the text-only 103-task validation subset of GAIA (Mialon et al., 2023) (GAIA-Text) for\ndeep research, and SWE-Verified (OpenAI, 2024) for software engineering. Benchmark setup details are provided in Appendix A.2.1.\nMetrics. We report success rate and mean per-task API cost for the main agent and its contextsummary calls, in US cents unless otherwise specified. Costs are computed from active input and\ngenerated output tokens using Groq’s rates (Groq, n.d.) for GPT-OSS-120B and MiniMax’s official\nrates for MiniMax-M2.7. For MiroThinker-1.7-Mini, we use the official rates of its base model,\nQwen3-30B-A3B (Yang et al., 2025). Detailed token prices are listed in Table 6. We additionally\ncharge each token repos by AKV at the cache-hit rate, deliberately overestimating the cost of key\nrotation for a conservative comparison. For serving efficiency, we report request latency, time to\nfirst token (TTFT), and time per output token (TPOT), together with input and output throughput.\nServing configuration. Baselines run on SGLang (Zheng et al., 2024), which is also the base\nserving system of AKV. Serving experiments use eight NVIDIA A800-80GB GPUs: four for prefill\nand four for decode, with tensor parallelism of four. Since A800 GPU lacks native MXFP4 support,\nall LLM weights are set to BF16. Further details are in Appendix A.1.3.\n5.2\n\nP ERFORMANCE\n\nAgentic benchmark results. As shown in Table 1, AKV achieves the highest average success\nrates across three models, improving the average success rate by 1.3–2.1% and 0.9–8.7% compared\nwith two baselines, respectively. AKV also reduces inference cost by 27.7% relative to Standard\nand 21.9% relative to Text Engineering, averaged across all three models and four benchmarks.\nAppendix A.4.2 details the saving breakdown.\nSource of accuracy improvements. AKV better maintains accuracy beyond the baselines’ summarization thresholds. On the first 100 BCP tasks with GPT-OSS-120B, all three methods achieve\ncomparable accuracy below 48K logical tokens (Figure 7). Text Engineering has the lowest accuracy in the 48–96K range, while Standard is lowest above 96K, following their respective 48K and\n8\n\n\fPreprint version\n\nTable 1: Benchmark scores (pass rate, %) and costs (cents) by model and management method. Bold\nindicates the highest score and lowest cost within each model, including ties.\nBCP\n\nMethod\n\nScore\n\nCost\n\nGAIA-Text\n\nSWE-Verified\n\nxbench-DS\n\nScore\n\nScore\n\nScore\n\nCost\n\nCost\n\nAverage\n\nCost\n\nScore\n\nCost\n\n40.5\n40.0\n40.5\n\n5.5\n5.2\n4.7\n\n52.4\n52.8\n53.7\n\n5.0\n5.7\n4.4\n\n38.5\n38.5\n37.5\n\n6.2\n5.4\n3.8\n\n51.0\n48.3\n53.1\n\n11.2\n10.2\n7.3\n\n13.5\n15.3\n8.1\n\n44.1\n37.1\n45.8\n\n20.4\n18.1\n14.8\n\nMiniMax-M2.7 (230B total, 10B active)\nStandard\nText Engineering\nAKV\n\n58.9\n62.3\n58.9\n\n5.2\n5.3\n4.8\n\n35.0\n36.9\n40.8\n\n2.4\n2.7\n2.6\n\n75.2\n72.0\n74.4\n\n7.0\n9.4\n5.5\n\nGPT-OSS-120B (5.1B active)\nStandard\nText Engineering\nAKV\n\n57.5\n52.7\n61.9\n\n13.1\n12.6\n11.4\n\n68.0\n65.1\n69.9\n\n5.4\n6.8\n4.1\n\n40.0\n36.8\n43.2\n\n20.0\n15.8\n9.7\n\nMiroThinker-1.7-Mini (30B total, 3B active)\nStandard\nText Engineering\nAKV\n\n60.0\n45.7\n63.5\n\n25.2\n17.6\n15.3\n\n68.0\n66.0\n68.9\n\n9.2\n11.0\n9.5\n\n7.8\n4.2\n7.4\n\n33.6\n28.4\n26.3\n\n40.5\n32.5\n43.5\n\nTable 2: Serving performance (latency, s; TTFT, s; TPOT, ms/token; throughput, tokens/s) of GPTOSS-120B on Top-80 SWE-Verified across concurrency (C) levels.\nC Method\n\nRequest latency\n\nTTFT\n\nTPOT\n\nThroughput\n\nmean\n\nP95\n\nmean\n\nP95\n\nmean\n\nP95\n\nInput Output\n\nStandard\n8 Text Engineering\nAKV\n\n12.16\n12.84\n7.79\n\n43.57\n43.57\n25.93\n\n3.18\n4.94\n1.87\n\n8.42\n22.99\n5.99\n\n26.57\n23.23\n23.50\n\n31.38\n25.68\n29.42\n\n25200\n17313\n39227\n\n217\n228\n245\n\nStandard\n10 Text Engineering\nAKV\n\n12.82\n15.17\n8.13\n\n45.03\n50.27\n27.11\n\n3.93\n7.35\n2.22\n\n9.76\n34.07\n7.36\n\n26.47\n22.57\n23.20\n\n30.83\n25.09\n29.86\n\n30108\n18533\n46002\n\n254\n246\n295\n\nStandard\n12 Text Engineering\nAKV\n\n12.39\n16.83\n8.47\n\n43.16\n52.82\n27.18\n\n2.97\n8.86\n2.60\n\n9.99\n37.98\n8.17\n\n28.00\n23.24\n23.06\n\n32.78\n25.95\n29.23\n\n33832\n19945\n48923\n\n313\n264\n339\n\nStandard\n14 Text Engineering\nAKV\n\n30.16\n19.59\n9.09\n\n108.86\n60.67\n28.49\n\n21.36\n11.19\n2.92\n\n88.29\n47.36\n8.62\n\n24.50\n24.50\n24.50\n\n29.85\n27.23\n31.56\n\n12767\n19992\n51837\n\n146\n267\n369\n\nStandard\n16 Text Engineering\nAKV\n\n36.50\n23.00\n10.32\n\n229.90\n69.96\n30.63\n\n27.71\n14.48\n4.16\n\n223.57\n52.71\n13.02\n\n24.83\n24.44\n24.84\n\n29.25\n27.56\n32.41\n\n10866\n19595\n50817\n\n138\n267\n369\n\n96K summarization thresholds. This pattern is consistent with information loss from abrupt context\nreductions, whereas rolling drop removes older tool-response cache incrementally, as in Figure 14.\n5.3\n\nE FFICIENCY\n\nServing efficiency. As shown in Table 2, AKV achieves higher throughput and lower request latency\nthan both baselines across concurrency levels. At their respective peak-throughput settings, AKV\n(C = 14) achieves 1.36× and 1.51× speedups in mean and P95 request latency over Standard\n(C = 12), respectively. Input and output throughput are 1.53× and 1.18× those of Standard. Here,\ninput throughput counts all logical input tokens, including those whose cache has been dropped. The\nworkload and measurement protocol are detailed in Appendix A.1.4. AKV’s throughput and latency\n9\n\n\fPreprint version\n\nTable 3: Drop-target and repos ablations with GPT- Table 4: Agentic cache reduction on a 100OSS-120B on each benchmark’s first 100 tasks.\ntask BCP subset. CAT means Cache-As-Tool.\nStrategy\n\nRepos\n\nBCP\n\nSWE\n\nModel\n\nStandard\nTool drop\nReasoning drop\nBoth drop\nTool drop\n\n✗\n✗\n✓\n✓\n✓\n\n56.0\n55.0\n56.5\n56.5\n62.0\n\n13.5\n7.1\n8.2\n8.7\n10.9\n\n41.0\n41.0\n36.5\n34.5\n41.0\n\n19.1\n9.4\n14.2\n7.8\n9.5\n\nMethod\n\nMetric\n\nScore Cost Score Cost\n\nStandard Text Eng. CAT\nGPT-OSS- Score\n120B\nCost\n\n52.1\n13.4\n\n50.0\n13.9\n\n61.0\n12.1\n\nMiniMax- Score\nM2.7\nCost\n\n56.0\n5.4\n\n61.0\n5.5\n\n64.0\n5.9\n\nadvantages over Standard widen at high concurrency (C ≥ 14), as KV-cache pressure increases\nStandard’s re-prefill work. As a result, fewer Standard requests can decode concurrently, yielding\nhigher end-to-end latency and lower throughput.\nSource of efficiency improvements. Figure 12 in Appendix A.4.1 shows that the decode speedup\ncomes mainly from reduced full-attention time. Dropping older tool-response cache shortens the\nactive context, reducing both KV reads and attention computation at each decode step.\nReal-world task acceleration. In Figure 9(a), AKV reaches the highest final pass rate in the least\nGPU time. This online evaluation uses GPT-OSS-120B on the first 100 SWE-bench Verified tasks,\nwith each method running at its peak-throughput concurrency. This advantage combines gains in\ntask performance and serving efficiency. Figure 9(b) shows that AKV continues to improve its\npass rate as cumulative logical input tokens increase, ultimately outperforming both baselines. Figure 9(c) shows higher peak serving throughput, allowing AKV to process these trajectories faster.\n5.4\n\nA BLATIONS AND C ACHE E NGINEERING P OLICIES\n\nAblation study. Table 3 compares drop targets and the use of repos, showing that tool-response\ndrop with repos achieves the highest pass rate on both benchmarks. Adding repos raises BCP’s pass\nrate from 55% to 62%, allowing exploration beyond the position limit that would otherwise halt execution. With repos enabled, dropping reasoning cache, either alone or together with tool-response\ncache, yields lower pass rates on both benchmarks than dropping tool-response cache alone.\nRecursive self-improvement (RSI). Figure 4 shows that RSI finds lower-cost cache policies than\nour manually designed tool-response rolling-drop policy (K = 12) while maintaining Standard’s\naccuracy. We use MiniMax-M2.7 to refine policies on 20 BCP tasks and evaluate the resulting\npolicies on 100 held-out tasks. The policies from iterations 3 and 6 reduce per-task cost by 15.6%\nand 17.8% relative to Standard, respectively.\nCache management as a tool. Exposing cache management as a tool lets agents proactively decide\nwhen to reduce the cache and what to retain. Table 4 shows that this approach achieves the highest\npass rate on a 100-task BCP subset for both models: 61.0% for GPT-OSS-120B and 64.0% for\nMiniMax-M2.7. Compared with Standard, GPT-OSS-120B’s per-task cost falls from 13.4 to 12.1\ncents, while MiniMax-M2.7’s rises from 5.4 to 5.9 cents as it executes more turns.\n\n6\n\nC ONCLUSION\n\nWe introduce cache engineering, enabling agents to directly manage active KV states while reusing\nretained caches without recomputation. We co-design the AKV serving system to support cache\nengineering through a stateless interface, an extended radix tree, and segment-batch attention for efficient cache reuse, eviction, and restoration. Across agent benchmarks, cache engineering improves\naverage task performance while reducing inference costs, with AKV translating these efficiency\ngains into higher serving throughput and lower latency.\nLimitations. Further exploration of cache engineering strategies, training agents under this scheme,\nand extending serving support to linear attention models remain future work.\n\n10\n\n\fPreprint version\n\nACKNOWLEDGEMENTS\nThis work was supported by National Natural Science Foundation of China (No. 62506197,\n62325405, 62104128, U19B2019, U21B2031, 61832007, 62204164, 92364201), Tsinghua EE Xilinx AI Research Fund, and Beijing National Research Center for Information Science and Technology (BNRist). We thank all the support from Infinigence-AI.\n\nR EFERENCES\nSandhini Agarwal, Lama Ahmad, Jason Ai, Sam Altman, Andy Applebaum, Edwin Arbus, Rahul K\nArora, Yu Bai, Bowen Baker, Haiming Bao, et al. gpt-oss-120b &amp; gpt-oss-20b model card. arXiv\npreprint arXiv:2508.10925, 2025.\nAnthropic. Introducing claude fable 5.1 and claude mythos 5.1, 2026. URL https://www.\nanthropic.com/claude-fable-and-mythos-5-1.\nAnthropic. How Claude Code uses prompt caching. Claude Code documentation, n.d. URL\nhttps://code.claude.com/docs/en/prompt-caching. Accessed September 22,\n2026.\nAili Chen, Aonian Li, Baichuan Zhou, Bangwei Gong, Binyang Jiang, Boji Dan, Changhao Zhang,\nChangqing Yu, Chao Wang, Cheng Ma, et al. The minimax-m2 series: Mini activations unleashing max real-world intelligence. arXiv preprint arXiv:2605.26494, 2026a.\nGuoxin Chen, Zile Qiao, Xuanzhong Chen, Donglei Yu, Haotian Xu, Wayne Xin Zhao, Ruihua\nSong, Wenbiao Yin, Huifeng Yin, Liwen Zhang, Kuan Li, Minpeng Liao, Yong Jiang, Pengjun\nXie, Fei Huang, and Jingren Zhou. Iterresearch: Rethinking long-horizon agents with interaction\nscaling, 2026b. URL https://arxiv.org/abs/2511.07327.\nZijian Chen, Xueguang Ma, Shengyao Zhuang, Ping Nie, Kai Zou, Andrew Liu, Joshua Green,\nKshama Patel, Ruoxi Meng, Mingyi Su, Sahel Sharifymoghaddam, Yanxi Li, Haoran Hong,\nXinyu Shi, Xuye Liu, Nandan Thakur, Crystina Zhang, Luyu Gao, Wenhu Chen, and Jimmy Lin.\nBrowsecomp-plus: A more fair and transparent evaluation benchmark of deep-research agent,\n2025. URL https://arxiv.org/abs/2508.06600.\nearendil-works. pi: AI agent toolkit: unified LLM API, agent loop, TUI, coding agent CLI.\nGitHub repository, 2026. URL https://github.com/earendil-works/pi. Commit\nce5ec9ca355a852fb1f25c088cf409df47a95213; accessed September 26, 2026.\nTianyu Fu, Haofeng Huang, Xuefei Ning, Genghan Zhang, Boju Chen, Tianqi Wu, Hongyi Wang,\nZixiao Huang, Shiyao Li, Shengen Yan, Guohao Dai, Huazhong Yang, and Yu Wang. Moa:\nMixture of sparse attention for automatic large language model compression, 2025a. URL\nhttps://openreview.net/forum?id=konDsSUSqg.\nTianyu Fu, Tengxuan Liu, Qinghao Han, Guohao Dai, Shengen Yan, Huazhong Yang, Xuefei Ning,\nand Yu Wang. Framefusion: Combining similarity and importance for video token reduction on\nlarge vision language models. In 2025 IEEE/CVF International Conference on Computer Vision\n(ICCV), pp. 22654–22663. IEEE, 2025b.\nTianyu Fu, Zihan Min, Hanling Zhang, Jichao Yan, Guohao Dai, Wanli Ouyang, and Yu Wang.\nCache-to-cache: Direct semantic communication between large language models. In International Conference on Learning Representations, volume 2026, pp. 43130–43158, 2026.\nBin Gao, Zhuomin He, Puru Sharma, Qingxuan Kang, Djordje Jevdjic, Junbo Deng, Xingkun Yang,\nZhou Yu, and Pengfei Zuo. {Cost-Efficient} large language model serving for multi-turn conversations with {CachedAttention}. In 2024 USENIX annual technical conference (USENIX ATC\n24), pp. 111–126, 2024.\nGroq. Supported models. Groq documentation, n.d. URL https://console.groq.com/\ndocs/models. Accessed October 15, 2026.\n11\n\n\fPreprint version\n\nCheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang\nZhang, and Boris Ginsburg. Ruler: What’s the real context size of your long-context language\nmodels?, 2024. URL https://arxiv.org/abs/2404.06654.\nMinki Kang, Wei-Ning Chen, Dongge Han, Huseyin A Inan, Lukas Wutschitz, Yanzhi Chen, Robert\nSim, and Saravan Rajmohan. Acon: Optimizing context compression for long-horizon llm agents.\narXiv preprint arXiv:2510.00615, 2025.\nSanjay Kariyappa and G Edward Suh. Sidequest: Model-driven kv cache management for longhorizon agentic reasoning. arXiv preprint arXiv:2602.22603, 2026.\nWoosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph\nGonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model\nserving with pagedattention. In Proceedings of the 29th symposium on operating systems principles, pp. 611–626, 2023.\nJunjie Li, Jiong Lou, and Jie Li. Intentkv: Cross-turn intent-aware kv cache pruning for agent\ninference. arXiv preprint arXiv:2606.09916, 2026.\nYuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyr Locatelli, Hanchen Ye, Tianle\nCai, Patrick Lewis, and Deming Chen. Snapkv: Llm knows what you are looking for before\ngeneration. Advances in Neural Information Processing Systems, 37:22947–22970, 2024.\nTobias Lindenbauer, Igor Slinko, Ludwig Felder, Egor Bogomolov, and Yaroslav Zharov. The complexity trap: Simple observation masking is as efficient as llm summarization for agent context\nmanagement. arXiv preprint arXiv:2508.21433, 2025.\nAixin Liu, Bei Feng, Bin Wang, Bingxuan Wang, Bo Liu, Chenggang Zhao, Chengqi Dengr, Chong\nRuan, Damai Dai, Daya Guo, et al. Deepseek-v2: A strong, economical, and efficient mixtureof-experts language model. arXiv preprint arXiv:2405.04434, 2024a.\nJunteng Liu, Yunji Li, Chi Zhang, Jingyang Li, Aili Chen, Ke Ji, Weiyu Cheng, Zijia Wu,\nChengyu Du, Qidi Xu, Jiayuan Song, Zhengmao Zhu, Wenhu Chen, Pengyu Zhao, and Junxian He. WebExplorer: Explore and evolve for training long-horizon web agents, 2025a. URL\nhttps://arxiv.org/abs/2509.06501.\nShukai Liu, Jian Yang, Bo Jiang, Yizhi Li, Jinyang Guo, Xianglong Liu, and Bryan Dai. Context\nas a tool: Context management for long-horizon swe-agents, 2025b. URL https://arxiv.\norg/abs/2512.22087.\nTaowen Tony Liu, Jeffrey TH Wong, Can Xiao, Bowen Yang, Hao Mark Chen, and Yiren Zhao.\nAgentkv: Phase-aware kv eviction for agentic llms. arXiv preprint arXiv:2609.14872, 2026a.\nTengxuan Liu, Shiyao Li, Jiayi Yang, Tianchen Zhao, Feng Zhou, Xiaohui Song, Guohao Dai,\nShengen Yan, Huazhong Yang, and Yu Wang. Pm-kvq: Progressive mixed-precision kv cache\nquantization for long-cot llms. In International Conference on Learning Representations, volume\n2026, pp. 107881–107900, 2026b.\nZirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi\nChen, and Xia Hu. Kivi: A tuning-free asymmetric 2bit quantization for kv cache. arXiv preprint\narXiv:2402.02750, 2024b.\nMiao Lu, Weiwei Sun, Weihua Du, Zhan Ling, Xuesong Yao, Kang Liu, and Jiecao Chen. Scaling llm multi-turn rl with end-to-end summarization-based context management. arXiv preprint\narXiv:2510.06727, 2025.\nBole Ma, Jan Eitzinger, and Harald Köstler. Irminsul: Mla-native position-independent caching for\nagentic llm serving. arXiv preprint arXiv:2605.05696, 2026.\nGrégoire Mialon, Clémentine Fourrier, Craig Swift, Thomas Wolf, Yann LeCun, and Thomas\nScialom. Gaia: a benchmark for general ai assistants, 2023. URL https://arxiv.org/\nabs/2311.12983.\n12\n\n\fPreprint version\n\nOpenAI. Introducing SWE-bench Verified. OpenAI, 2024. URL https://openai.com/\nindex/introducing-swe-bench-verified/. Updated February 24, 2025.\nOpenAI. Unrolling the codex agent loop, 2026. URL https://openai.com/index/\nunrolling-the-codex-agent-loop/. OpenAI Engineering Blog.\nOpenAI. Developer commands. OpenAI documentation, n.d. URL https://learn.\nchatgpt.com/docs/developer-commands?surface=cli. Accessed September 22,\n2026.\nNathan Ordonez and Thomas Parnell. Minipic: Flexible position-independent caching in¡ 100loc.\narXiv preprint arXiv:2606.13126, 2026.\nZaifeng Pan, Qianxu Wang, Zhengding Hu, Chang Chen, Yue Guan, Yanbo Zhou, Steven Swanson,\nand Yufei Ding. Smoothagent: Efficient long-horizon llm-based agent serving with lookahead\ncontext engineering. arXiv preprint arXiv:2607.00151, 2026.\nPi. Compaction reference, 2026. URL https://pi.dev/docs/latest/compaction. Accessed October 15, 2026.\nRulin Shao, Shannon Zejiang Shen, Junjie Oscar Yin, Yuetai Li, Minheng Wang, Hamish Ivison,\nRadha Poovendran, Nathan Lambert, Teng Xiao, Mike Lewis, et al. Context language models.\narXiv preprint arXiv:2609.37725, 2026.\nJianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding, 2023. URL https://arxiv.org/abs/\n2104.09864.\nWeiwei Sun, Miao Lu, Zhan Ling, Kang Liu, Xuesong Yao, Yiming Yang, and Jiecao Chen. Scaling\nlong-horizon llm agent via context-folding. arXiv preprint arXiv:2510.11967, 2025.\nMiroMind Team, S Bai, L Bing, L Lei, R Li, X Li, X Lin, E Min, L Su, B Wang, et al. Mirothinker1.7 &amp; h1: Towards heavy-duty research agents via verification. arXiv preprint arXiv:2603.15726,\n2026.\nLuning Wang, Shiyao Li, Xuefei Ning, Zhihang Yuan, Shengen Yan, Guohao Dai, and Yu Wang.\nCskv: Training-efficient channel shrinking for kv cache in long-context scenarios. arXiv preprint\narXiv:2409.10593, 2024a.\nQian Wang, Zahra Yousefijamarani, Morgan Lindsay Heisler, Rongzhi Gu, Bai Xiaolong, Shan\nYizhou, Wei Zhang, Wang Lan, Ying Xiong, Yong Zhang, et al. Mepic: Memory efficient position\nindependent caching for llm serving. arXiv preprint arXiv:2512.16822, 2025.\nZheng Wang, Boxiao Jin, Zhongzhi Yu, and Minjia Zhang. Model tells you where to merge: Adaptive kv cache merging for llms on long-context tasks. arXiv preprint arXiv:2407.08454, 2024b.\nXixi Wu, Kuan Li, Yida Zhao, Liwen Zhang, Litu Ou, Huifeng Yin, Zhongwang Zhang, Xinmiao\nYu, Dingchu Zhang, Yong Jiang, et al. Resum: Unlocking long-horizon search intelligence via\ncontext summarization. arXiv preprint arXiv:2509.13313, 2025.\nYongtong Wu, Shaoyuan Chen, Yinmin Zhong, Rilin Huang, Yixuan Tan, Wentao Zhang, Liyue\nZhang, Shangyan Zhou, Yuxuan Liu, Shunfeng Zhou, et al. Dualpath: breaking the storage\nbandwidth bottleneck in agentic llm inference. arXiv preprint arXiv:2602.21548, 2026.\nxbench.\nxbench-DeepSearch-2510.\nHugging Face dataset, 2025.\nURL https://\nhuggingface.co/datasets/xbench/DeepSearch-2510. Accessed September 24,\n2026.\nGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming\nlanguage models with attention sinks. In International Conference on Learning Representations,\nvolume 2024, pp. 21875–21895, 2024.\nBuqiang Xu, Zirui Xue, Dianmou Chen, Chenyang Fu, Chiyu Wu, Caiying Huang, Chen Jiang,\nJizhan Fang, Xinle Deng, Yijun Chen, et al. Tokenpilot: Cache-efficient context management for\nllm agents. arXiv preprint arXiv:2606.17016, 2026.\n13\n\n\fPreprint version\n\nAn Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu,\nChang Gao, Chengen Huang, Chenxu Lv, et al. Qwen3 technical report. arXiv preprint\narXiv:2505.09388, 2025. URL https://arxiv.org/abs/2505.09388.\nJohn Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik R.\nNarasimhan, and Ofir Press. SWE-agent: Agent-computer interfaces enable automated software\nengineering. In The Thirty-eighth Annual Conference on Neural Information Processing Systems,\n2024. URL https://arxiv.org/abs/2405.15793.\nXintong Yang, Hao Gu, Binxing Xu, Lujun Li, Bei Liu, Jiacheng Liu, Qiyuan Zhu, Yike Guo,\nand Sirui Han. Indexmem: Learned kv-cache eviction with latent memory for long-context llm\ninference. arXiv preprint arXiv:2605.25475, 2026.\nLu Ye, Ze Tao, Yong Huang, and Yang Li. Chunkattention: Efficient self-attention with prefix-aware\nkv cache and two-phase partition. In Proceedings of the 62nd Annual Meeting of the Association\nfor Computational Linguistics (Volume 1: Long Papers), pp. 11608–11620, 2024.\nRui Ye, Zhongwang Zhang, Kuan Li, Huifeng Yin, Zhengwei Tao, Yida Zhao, Liangcai Su, Liwen\nZhang, Zile Qiao, Xinyu Wang, et al. Agentfold: Long-horizon web agents with proactive context\nmanagement. arXiv preprint arXiv:2510.24699, 2025.\nZ.ai. GLM-5.2: Built for long-horizon tasks, June 2026. URL https://z.ai/blog/glm-5.\n2.\nHaoxiang Zhang, Qixin Xu, Zhuofeng Li, Lei Zhang, Pengcheng Jiang, Yu Zhang, and Julian\nMcAuley. Masking stale observations helps search agents–until it doesn’t: A regime map and\nits mechanism. arXiv preprint arXiv:2606.00408, 2026.\nYanzhao Zhang, Mingxin Li, Dingkun Long, Xin Zhang, Huan Lin, Baosong Yang, Pengjun\nXie, An Yang, Dayiheng Liu, Junyang Lin, Fei Huang, and Jingren Zhou. Qwen3 Embedding: Advancing text embedding and reranking through foundation models. arXiv preprint\narXiv:2506.05176, 2025. URL https://arxiv.org/abs/2506.05176.\nZhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song,\nYuandong Tian, Christopher Ré, Clark Barrett, et al. H2o: Heavy-hitter oracle for efficient generative inference of large language models. Advances in neural information processing systems,\n36:34661–34710, 2023.\nLianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody H Yu, Shiyi Cao,\nChristos Kozyrakis, Ion Stoica, Joseph E Gonzalez, et al. Sglang: Efficient execution of structured\nlanguage model programs. Advances in neural information processing systems, 37:62557–62583,\n2024.\nZijian Zhou, Ao Qu, Zhaoxuan Wu, Sunghwan Kim, Alok Prakash, Daniela Rus, Jinhua Zhao,\nBryan Kian Hsiang Low, and Paul Pu Liang. Mem1: Learning to synergize memory and reasoning\nfor efficient long-horizon agents, 2025. URL https://arxiv.org/abs/2506.15841.\nJiaru Zou, Ruizhong Qiu, Gaotang Li, Xiyuan Yang, Katherine Tieu, Pan Lu, Ke Shen, Hanghang\nTong, Yejin Choi, Jingrui He, et al. Latent collaboration in multi-agent systems. arXiv preprint\narXiv:2511.20639, 2025.\n\n14\n\n\fPreprint version\n\nA\n\nA PPENDIX\n\nA.1\n\nAKV S YSTEM D ESIGN D ETAILS\n\nA.1.1\n\nR ESTORE WITH S EGMENT- BATCH ATTENTION\n\nSegmentation. Building on Sections 4.2.2 and 4.2.3, AKV restores missing KV states by partitioning queries whenever a drop or repos operation changes the visible history or its position mapping.\nEach segment selects the corresponding KV pages and applies standard causal attention, encoding\nhistorical visibility without constructing a dense custom mask.\n(a) Request\n\nA\n\nB\n\nC\n\n0\n\n1\n\n2\n\nD\n\nR\n\nΔB\n\nE\n\nΔD\n\n2\n\n(b) Segment attention\n\n3\n\nOne prefill forward\n\nSegment 1\n\nSegment 2\n\nK\n\nQ\n\nF\n\nR\n\n3\n\nSegment 3\n\nK\n\nSegment 4\n\nK\n\nK\n\nA\n\nB\n\nC\n\nA\n\nC\n\nD\n\nA\n\nC\n\nE\n\nA\n\nC\n\nE\n\nF\n\n0\n\n1\n\n2\n\n0\n\n1\n\n2\n\n0\n\n1\n\n3\n\n0\n\n1\n\n2\n\n3\n\nA\n0\n\nQ\n\nD\n2\n\nQ\n\nE\n3\n\nQ\n\nF\n3\n\nB\n1\n\nC\n2\n\nFigure 10: Restore with segment-batch attention. The request in (a) produces the four attention\nsegments in (b). Numbers denote query/key positions; colored cells indicate allowed attention.\nExample. Figure 10 illustrates a complete restoration, treating each letter as one token and writing\nXp for token X at position p. Segment 1 computes A0 , B1 , C2 with causal attention. After dropping\nB and repositioning, Segment 2 computes D2 using keys (A0 , C1 , D2 ). Dropping D starts Segment\n3: E3 attends to (A0 , C1 , E3 ). Although Segments 2 and 3 share a position mapping, they require\nseparate KV views because D is no longer visible to E; drop alone does not compact positions. The\nsecond repos moves E from position 3 to 2, so Segment 4 computes F3 using (A0 , C1 , E2 , F3 ).\nBatched restoration. Within each layer, AKV writes the newly computed KV states and constructs\nthe additional position versions, such as C1 and E2 , by re-encoding K and copying V. The segmentspecific page lists and query ranges are then submitted together to batched attention. Thus, all four\nsegments execute within a single model forward pass, without recomputing hidden states for each\nposition version or replaying separate forward passes at operation boundaries.\nA.1.2\n\nR EPOSITION S CHEME\n\nDesign objective. Reposition-aware cache management must distinguish positional versions while\nreusing their shared computational states. We therefore first identify directly reusable caches via\nexact matching, then use retrigger matching to find prefixes that are reusable via positional transformation, avoiding unnecessary hidden-state recomputation.\nToken-node representation. Each token node is represented as T (x, p), where x is the token ID\nand p is the position currently encoded in its cached K. The position label describes the stored cache,\nnot necessarily the position at which the token was originally computed. For example, C is initially\ncomputed at position 2 in all three trajectories in Figure 11. After repos, trajectories 1 and 3 use\n(C, 0), while trajectory 2 uses (C, 1). Operation nodes along the path preserve the operation history\nthat governs computation.\nWhy position labels and reposition nodes are needed.\nPosition labels distinguish cache representations that cannot be used interchangeably. For example,\nC has the same original computation history in trajectories 1 and 2, but is repositioned to 0 and 1,\nrespectively. Its K encodings therefore differ and require positional transformation before reuse.\nReposition nodes distinguish states that share final positions but arise from different computations.\nTrajectories 1 and 3 both drop B after ABC, but trajectory 3 executes RC before computing D.\n15\n\n\fPreprint version\n\nWhen D is computed, the positions of A, C, and D are respectively (0, 2, 3) and (0, 1, 2). The\nrelative distance between D and A changes, while that between D and C remains unchanged, potentially producing different hidden states and KV entries for D. Both trajectories subsequently drop\nA and execute RD to move C and D to positions 0 and 1. This later transformation cannot erase the\ncomputational difference already established in D. The path must therefore retain RC before D to\nprevent incorrect reuse of D and subsequent cached states.\nExact and retrigger matching. Exact matching compares all token-node fields:\nT (x, p) ≡ T (x′ , p′ ) ⇐⇒ x = x′ ∧ p = p′ ,\nand requires identical operation nodes and their parameters. Retrigger matching ignores only stored\nposition encoding indices while preserving all operation records:\nϕ(T (x, p)) = T (x),\n\nϕ(∆P ) = ∆P,\n\nϕ(R) = R.\n\nTwo prefixes are history-compatible if their projections are identical.\nThe system initializes the result with the longest valid exact prefix, then searches compatible\nbranches from the root. A candidate replaces the current result only if it is valid and matches a\nstrictly longer prefix, preserving exact matches in a tie. Retrigger matching stops at the first token\nor operation mismatch. Selected source caches are copied and positionally transformed as needed\nbefore use.\nCorrectness of retrigger matching. Under fixed model and position encoding configurations and\nexact arithmetic, identical projected prefixes preserve the token and operation history preceding each\ntoken’s original computation. They therefore produce the same hidden states and unrotated KV\ncontent. Repos operations applied afterward change only K’s positional representation, allowing a\nsource version s to be transformed into a target version t as\nKt = R(pt )R(ps )−1 Ks ,\n\nVt = Vs ,\n\nwithout recomputing hidden states.\nPreserving operation nodes prevents this transformation from crossing a divergence in computational history. For example, trajectories 1 and 3 disagree at RC before D, so retrigger matching\ncannot reuse D across them. Finite-precision transformations may introduce rounding error; this\ncorrectness argument does not require bitwise equivalence to recomputation.\nA.1.3\n\nS ERVING C ONFIGURATION\n\nAKV is implemented on SGLang v0.5.20. Table 5 summarizes the configuration used for the serving\nexperiments. All three methods use GPT-OSS-120B with weights expanded to BF16 on eight A800\nGPUs, with separate prefill and decode workers. Both workers enable radix caching; the baselines\nuse LRU eviction, while AKV enables drop-aware eviction.\nTable 5: Serving configuration.\nSetting\n\nValue\n\nModel and weight precision\nHardware\nParallelism\nKV transfer\nAttention backend\nMoE backend\nStatic memory fraction\nKV page size\nPrefill chunk size\nMaximum prefill tokens\nPrefix caching\nEviction\n\nGPT-OSS-120B, BF16\nEight NVIDIA A800 GPUs, 80 GB each\nPrefill: TP4; decode: TP4\nMooncake over intra-node NVLink\nTriton\ntriton kernel\n0.85\nOne token per page\n8,192 tokens\n8,192\nRadix cache enabled on both workers\nBaselines: LRU; AKV: drop-aware eviction\n\n16\n\n\fPreprint version\n\n(a) Message trajectories\n\n(b) Radix tree\nroot\n\n+ Append\n\n− Drop KV\n\nR Reposition\n\nA\n\n0\n\nB\n\n1\n\nStep\n\n1\n\n2\n\n3\n\nInitial\n\n+ A B C\n\n+ A B C\n\n+ A B C\n\nDrop\n\n− B\n\n− B\n\n− B\n\nReposition\n\n−\n\n−\n\nRC\n\nAppend\n\n+ D\n\n+ D\n\n+ D\n\nDrop\n\n− A\n\n−\n\n− A\n\nReposition\n\nRD\n\nRD\n\nRD\n\n+ E\n\n+ E\n\n+ E\n\nC D E\n\nA C D E\n\nC D E\n\nE\n\n0 1 2\n\n0 1 2 3\n\n0 1 2\n\n3\n\nC\n\nC\n\n1\n\nΔB\n\nD\n\nΔB\n2\n\nRD\n\nE\n\nAppend\n\n3\n\n2\n\nD\n\n1\n\nRC\n\nΔA\n\nD\n\nRD\n\nΔA\n\nE\n1\n\nRetained KV\n\n0\n\n2\n\n1\n\nRD\n2\n\nFigure 11: Encoding drop and reposition histories in the extended radix tree. (a) Three message\ntrajectories interleave token appends, KV drops, and reposition operations. Although their retained\ntokens overlap, applying the operations at different points produces different KV states. (b) AKV\nrecords each operation in the radix tree, distinguishing cache versions by position and operation\nhistory. Numbers beside token nodes denote stored position encoding indices; RX denotes repos\nafter X.\n\nA.1.4\n\nW ORKLOAD R EPLAY AND E VALUATION P ROTOCOL\n\nTask selection. To emulate realistic long-horizon agent workloads with substantial accumulated\ncontext, we select the 80 SWE-bench Verified tasks with the largest context lengths in trajectories,\nwithout any summary operation. These tasks reflect the difficulty of tasks in long-context reasoning.\nWe rank tasks by this peak length and shuffle the selected tasks with a fixed seed. All methods use\nthe same tasks and ordering. Each method replays trajectories collected under its own context/cache\nengineering policy, so the number of turns and the output budgets may differ between methods.\nTrajectory replay. For each turn, we reconstruct the output token budget from the complete\nrecorded message history, including reasoning and tool-call content, after subtracting the generation prefix already present in the input. We use temperature 0 and ignore eos=True to generate\nthe prescribed number of tokens. The newly generated assistant response is retained in the history\nfor subsequent turns, while tool responses are replayed from the recorded trajectory rather than reexecuting the tools. Recorded terminal inputs without an available assistant response are excluded\nfrom replay.\nConcurrency and measurement windows. We maintain C client task concurrency and execute\nturns sequentially within each task. The task-count target for each measurement window is max(3×\nC, 30); measurements include requests from supplemental tasks used to maintain concurrency. For\nAKV at C ∈ {14, 16}, we truncate the archived runs at the completion of the first 30 tasks in\ncompletion order, counting all requests within the resulting window rather than only requests from\nthose 30 completed tasks. For Standard at large concurrency, KV cache capacity pressure causes\nrepeated prefill, resulting in severe serving degradation. We therefore report these two runs over a\nfixed one-hour window, with some requests still unfinished at the cutoff.\n17\n\n\fPreprint version\n\nA.2\n\nA.2.1\n\nE XPERIMENTAL D ETAILS\n\nE VALUATION C ONFIGURATIONS\n\nEvaluation harnesses. We adapt the official BrowseComp-Plus harness, mini-SWE-agent (Yang\net al., 2024), the browser-agent scaffold from observation-masking (Zhang et al., 2026), and WebExplorer’s evaluation harness (Liu et al., 2025a) for BCP, SWE-bench Verified, GAIA-Text, and\nxbench-DeepSearch-2510, respectively.\nRetrieval and webpage reading. BCP evaluation follows the official task prompts and uses Qwen3Embedding-8B (Zhang et al., 2025) to retrieve documents from the benchmark’s fixed corpus. All\nmodels and methods have access to both search and the official optional get document tool,\nwhich returns the full text of a selected document. For xbench-DeepSearch-2510, we use GLM5.2 (Z.ai, 2026) to extract information from webpages in response to the agent’s queries.\nAnswer grading. We use GLM-5.2 as the answer judge for all three question-answering benchmarks. The grading prompts follow the official BCP implementation for BCP, observation-masking\nfor GAIA-Text, and WebExplorer for xbench-DeepSearch-2510. For SWE-bench Verified, submitted patches are evaluated using the official test scripts and grading functions; no LLM judge is used.\nAgent step limits. The agent step limits are 100 for BCP, 250 for SWE-bench Verified, 200 for\nGAIA-Text, and 100 for xbench-DeepSearch-2510.\n\nA.2.2\n\nC ONTEXT E NGINEERING BASELINE D ETAILS\n\nOur context engineering baselines adopt Pi’s summarization prompts, conversation serialization, cut-point selection, and summary-generation budgets (earendil-works, 2026), with\nreserveTokens=16,384 and keepRecentTokens=20,000 across experimental groups. Summarization uses the agent’s model and reasoning settings, replacing older dialogue with a summary\nwhile preserving system and developer instructions and the selected recent messages.\nUnlike Pi’s native trigger based on the context window minus the reserve-token budget, we trigger\ncompaction when the exact prompt token count reaches the threshold specified in Section 5.1. We\nalso reject empty summaries and handle summarization failures according to the benchmark error\nprotocol without retry.\nPi defines four prompt templates: a shared system prompt, an initial-summary prompt, an updatesummary prompt, and a turn-prefix prompt. For brevity, we reproduce the shared system and turnprefix prompts below. The turn-prefix prompt is appended to the serialized history in the summary\nrequest’s user message.\n\nText 1. Shared system prompt\nYou are a context summarization assistant. Your task is to read a\nconversation between a user and an AI assistant, then produce a\nstructured summary following the exact format specified.\nDo NOT continue the conversation. Do NOT respond to any questions\nin the conversation. ONLY output the structured summary.\n\n18\n\n\fPreprint version\n\nText 2. Turn-prefix prompt\nThis is the PREFIX of a turn that was too large to keep.\nSUFFIX (recent work) is retained.\n\nThe\n\nSummarize the prefix to provide context for the retained suffix:\n## Original Request\n[What did the user ask for in this turn?]\n## Early Progress\n- [Key decisions and work done in the prefix]\n## Context for Suffix\n- [Information needed to understand the retained recent work]\nBe concise.\n\nA.3\n\nFocus on what’s needed to understand the kept suffix.\n\nAPI C OST ACCOUNTING FOR E XPERIMENT\n\nWe estimate API-equivalent inference costs using the fixed token prices listed in Table 6. Our cost\naccounting includes only the evaluated agent’s generations and its context-summary calls. We use\nGroq’s rates (Groq, n.d.) for GPT-OSS-120B and GPT-OSS-20B, and MiniMax’s official rates for\nMiniMax-M2.7. For MiroThinker-1.7-Mini, we use the official rates of its base model, Qwen330B-A3B (Yang et al., 2025). Cache-miss, cache-hit, and output tokens are charged separately at\ndifferent rates, while using the same prices across different methods for the same model. For AKV’s\ncache repositioning, we also charge it at the cache-hit rate as a conservative estimate of the cost of\nkey rotation.\nTable 6: Token prices for API-equivalent cost rate (USD per million tokens).\nModel\nMiniMax-M2.7\nGPT-OSS-120B\nMiroThinker-1.7-Mini\nGPT-OSS-20B\n\nA.4\nA.4.1\n\nCache-miss\n\nCache-hit\n\nOutput\n\n0.300\n0.150\n0.200\n0.075\n\n0.060\n0.075\n0.040\n0.0375\n\n1.200\n0.600\n2.400\n0.300\n\nA DDITIONAL E XPERIMENT R ESULTS\nS PEEDUP B REAKDOWN\n\nAKV accelerates decoding primarily by reducing full-attention time. As shown in Figure 12, at the\nsame batch size, AKV reduces full-attention time by 59.8% and total decode-step time by 16.0%\nrelative to Standard. Dropping older tool-response KV shortens the active context, so subsequent\ndecode steps load less KV data from GPU memory and perform fewer attention computations.\nA.4.2\n\nC OST B REAKDOWN AND ACTIVE C ONTEXT L ENGTH\n\nCost breakdown. AKV lowers costs by reducing cache reads and repeated prefill. As shown in\nFigure 13, dropping older tool-response KV reduces the amount of cached history read by subsequent requests, lowering cache-read costs by approximately 17% relative to Standard. Compared\nwith Text Engineering, AKV reuses retained KV directly without the re-prefill required when summarization rewrites the history. This reduces re-prefill computation and lowers cache-miss input\ncosts by approximately 48%.\nActive context length. Figure 14 shows how AKV slows the growth of active context. Once tool\nresponses exceed the retention budget of K rounds, AKV continually drops older tool-response KV\nwhile retaining the most recent K rounds and reasoning KV. The active context therefore continues\nto grow as reasoning accumulates, but at a substantially slower rate. In contrast, Standard accumulates history until summarization triggers a sharp reduction in context length.\n19\n\n\fPreprint version\n\nTime / decode step (ms)\n\nFull attention\nSWA attention\nMoE (experts + routing)\n\n30\n\nAttention projections\nTP communication\nOther + gaps\n\n26.186\n0.839\n0.487\n0.866\n\n20\n\n21.990\n0.873\n0.468\n0.865\n\n16.764\n16.785\n\n10\n\n0.149\n\n7.082\n\n0\n\n2.849\n\nStandard\n\n0.149\n\nAKV\n\nFigure 12: Latency breakdown. Decode-step time for\nGPT-OSS-120B at the same batch size, broken down by operation.\n\n13.1\n1.6\n\n0.6\n\n10.0\n10.8\n\n5.0\n\n0.0\n\nStandard\n\nCache read\n\n12.6\n\nStandard\n\nRepos\n\n11.4\n\n1.2\n\n0.6\n0.3\n\n2.9\n\n1.5\n\n8.5\n\n9.0\n\nText\nengineering\n\nAKV\n\n96k\n\n80\n60\n40\n20\n0\n1\n\n20\n\n40\n\n60\n\n80\n\n100\n\nTurns\n\nFigure 13: Cost breakdown. Average cost per\ntask on BCP with GPT-OSS-120B for Standard,\nText Engineering, and AKV.\nA.4.3\n\nAKV\n\n100\n\nFigure 14: Active context length by turn.\nStandard and AKV on BCP over 100 turns. The\ndotted line marks 96k tokens.\n\nATTENTION ACROSS M ESSAGE H ISTORY\nOld reasoning\n\nOld tool\n\nRecent history\n\n2\n\nLayer index\n\n6\n\n10−4\n\n10\n\n10−5\n\n14\n18\n\n10−6\n\n22\n\n10−7\n\n26\n30\n\n10−8\n\n34\n10−9\n1\n\n9\n\n17\n\n25\n\n33\n\n41\n\n2\n\n10\n\n18\n\n26\n\n34\n\n42\n\n49\n\n53\n\n57\n\n61\n\n65\n\n69\n\nAttention density per token\n\nCost / task (cents)\n\nOutput\n\nInput length (k tokens)\n\nInput\n\n15.0\n\n72\n\nMessage index\n\nFigure 15: Attention density across message history. Attention density per token by layer and\nmessage index averaged over 10 selected BrowseComp-Plus trajectories, divided into old reasoning,\nold tool responses, and recent history.\nTo explain why our tool-response rolling-drop policy prioritizes dropping older tool-response KV\nentries, we analyze the attention allocated to different types of historical messages. Figure 15 shows\nattention per token across layers averaged over 10 BrowseComp-Plus trajectories. Older tool responses receive less attention than older reasoning in most displayed layers, while recent history\n20\n\n\fPreprint version\n\ngenerally receives more attention. This pattern suggests that direct attention to historical messages\ndepends on both recency and message type, providing empirical support for retaining recent tool\nresponses and reasoning while preferentially dropping older tool-response KV entries. Together\nwith the task performance and cost results reported earlier, this observation helps explain how AKV\nreduces KV-cache access while maintaining task performance.\nCompatibility with Harness. To assess whether AKV improves an existing harness, we integrate\nit with Pi (earendil-works, 2026) and evaluate the combination on BCP. For both GPT-OSS-120B\nand GPT-OSS-20B, adding AKV improves accuracy by 3% over the native Pi harness without compaction and 4% over the Pi harness with compaction.\nA.4.4\n\nA DDITIONAL M ODELS\n\nTable 7: Benchmark scores (pass rate, %) and costs (cents) of GPT-OSS-20B across different management methods. Bold indicates the highest score and lowest cost, including ties.\nMethod\nStandard\nText Engineering\nAKV\n\nBCP\n\nGAIA-Text\n\nSWE-Verified\n\nxbench-DS\n\nAverage\n\nScore\n\nCost\n\nScore\n\nCost\n\nScore\n\nCost\n\nScore\n\nCost\n\nScore\n\nCost\n\n49.0\n43.0\n50.5\n\n6.5\n4.4\n6.0\n\n60.2\n65.1\n62.1\n\n3.5\n3.0\n2.5\n\n41.8\n25.6\n44.2\n\n12.5\n8.8\n8.9\n\n25.0\n19.0\n24.0\n\n2.4\n2.0\n1.8\n\n44.0\n38.2\n45.2\n\n6.2\n4.6\n4.8\n\nWe further evaluate AKV on GPT-OSS-20B (Agarwal et al., 2025), a smaller model from the same\nmodel family as GPT-OSS-120B, and compare its pass rate and cost against the Standard and Text\nEngineering baselines. GPT-OSS-20B is evaluated with high reasoning effort across all methods.\nWe use the same thresholds as for GPT-OSS-120B: 96K tokens for Standard summarization and\nAKV’s repos, and 48K tokens for Text Engineering. As shown in Table 7, AKV achieves the highest\naverage pass rate of 45.2%, while maintaining a comparable average cost of 4.8 cents. In particular,\nAKV achieves the best pass rate on BCP and SWE-Verified, and the lowest cost on GAIA-Text\nand xbench-DS. On several metrics where AKV does not outperform the baselines, we attribute the\nsmaller gains to the more limited capability of GPT-OSS-20B: compared with GPT-OSS-120B, the\nsmaller model is less able to effectively leverage the retained information under cache engineering,\nmaking it more sensitive to cache modifications.\nA.5\n\nA DDITIONAL R ELATED W ORKS\n\nConcurrent works. Concurrent work adapts KV eviction to the changing attention needs of agent\ntrajectories. AgentKV (Liu et al., 2026a) scores KV entries using query buffers from different execution phases, retaining information that recency-based scoring can miss. IntentKV (Li et al., 2026)\ncombines cross-turn query memory with learned importance estimates to preserve useful history\nunder limited KV budgets. SideQuest (Kariyappa &amp; Suh, 2026) explores model-directed retention\nthrough an auxiliary reasoning branch that identifies stale tool results and issues cache-deletion commands, but its current strategy is limited to tool responses, and its serving integration is tailored to\nthis specific eviction workflow. Context Language Models (CLMs) (Shao et al., 2026) primarily\nstudy model-driven context management, treating the live context as an editable file and learning\nhow to maintain it. CLM also introduces Suffix Cache Reuse to preserve unchanged downstream\nKV states after text edits. Its serving support centers on session-local reuse: relocated states remain\nin private buffers outside the shared radix cache, without a unified mechanism for indexing, managing, and recovering these history-dependent states. AKV addresses these serving concerns directly\nby exposing policy-independent cache operations through a stateless interface and uses an extended\nradix tree to track both tokens and cache operation histories, integrating retained states into shared\ncache reuse, memory management, and recovery.\n\n21\n\n\f</code></pre></article>\n        \n</main>\n\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js\"></script>\n<script>\n\nfunction initTheme() {\n  const saved = localStorage.getItem('kb-theme') || 'light';\n  document.documentElement.setAttribute('data-theme', saved);\n  updateThemeIcon(saved);\n}\nfunction toggleTheme() {\n  const cur = document.documentElement.getAttribute('data-theme') || 'light';\n  const next = cur === 'light' ? 'dark' : 'light';\n  document.documentElement.setAttribute('data-theme', next);\n  localStorage.setItem('kb-theme', next);\n  updateThemeIcon(next);\n}\nfunction updateThemeIcon(t) {\n  const btn = document.getElementById('theme-toggle-btn');\n  if (btn) btn.innerHTML = t === 'dark' ? '☀️' : '🌙';\n}\ndocument.addEventListener('DOMContentLoaded', initTheme);\n\nfunction setViewMode(m) {\n  const grid = document.getElementById('bento-grid-view');\n  const list = document.getElementById('list-table-view');\n  const bGrid = document.getElementById('view-grid-btn');\n  const bList = document.getElementById('view-list-btn');\n  if (m === 'list') {\n    if (grid) grid.style.display = 'none';\n    if (list) list.style.display = 'flex';\n    if (bGrid) bGrid.classList.remove('active');\n    if (bList) bList.classList.add('active');\n  } else {\n    if (grid) grid.style.display = 'grid';\n    if (list) list.style.display = 'none';\n    if (bGrid) bGrid.classList.add('active');\n    if (bList) bList.classList.remove('active');\n  }\n  localStorage.setItem('kb-view', m);\n}\ndocument.addEventListener('DOMContentLoaded', () => {\n  const s = localStorage.getItem('kb-view') || 'grid';\n  setViewMode(s);\n});\n\ndocument.addEventListener('DOMContentLoaded', () => {\n  document.querySelectorAll('pre').forEach(pre => {\n    const b = document.createElement('button');\n    b.className = 'copy-code-btn';\n    b.innerText = 'Copy';\n    b.onclick = () => {\n      const c = pre.querySelector('code') ? pre.querySelector('code').innerText : pre.innerText;\n      navigator.clipboard.writeText(c).then(() => {\n        b.innerText = 'Copied!';\n        setTimeout(() => { b.innerText = 'Copy'; }, 2000);\n      });\n    };\n    pre.appendChild(b);\n  });\n});\n\nwindow.addEventListener('keydown', (e) => {\n  if ((e.key === '/' || (e.metaKey && e.key === 'k')) && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {\n    e.preventDefault();\n    const q = document.getElementById('global-search-input');\n    if (q) q.focus();\n  }\n});\n\n// Scrollspy for TOC\nwindow.addEventListener('scroll', () => {\n  const headers = document.querySelectorAll('.article-body h1, .article-body h2, .article-body h3');\n  const scrollPos = window.scrollY + 100;\n  headers.forEach(h => {\n    if (h.offsetTop <= scrollPos) {\n      const id = h.getAttribute('id');\n      if (id) {\n        document.querySelectorAll('.reading-sidebar a').forEach(a => {\n          a.classList.toggle('active', a.getAttribute('href') === '#' + id);\n        });\n      }\n    }\n  });\n});\n\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n  if (window.renderMathInElement) {\n    renderMathInElement(document.body, {\n      delimiters: [\n        {left: '$$', right: '$$', display: true},\n        {left: '$', right: '$', display: false},\n      ],\n      throwOnError : false\n    });\n  }\n});\n</script>\n\n</body>\n</html>\n"