Spaces:
Running
Running
Download index.html from vintces/Self-Context: direct link, hf CLI and curl.
- Browser
- Download file 108 kB
-
https://huggingface.co/spaces/vintces/Self-Context/resolve/main/index.html
- Command line
-
hf download hf://spaces/vintces/Self-Context/index.html
-
curl -L -o index.html https://huggingface.co/spaces/vintces/Self-Context/resolve/main/index.html
108 kB
<!DOCTYPE html>
<html lang="en" data-theme="light" data-lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents</title>
<meta name="description" content="Self-Context wraps a frozen LLM and its native agent harness in a drop-in context gateway: an editable working graph plus reversible whole-turn history folding (c_t = F_t ⊕ G_t).">
<link rel="canonical" href="https://self-context.github.io/">
<link rel="icon" type="image/svg+xml" href="static/images/favicon.svg">
<meta property="og:site_name" content="Self-Context">
<meta property="og:type" content="website">
<meta property="og:title" content="Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents">
<meta property="og:description" content="Harnesses stuff the prompt. Self-Context lets the model curate it: +5.7 pp macro-average gain and 23.7% fewer turns on Qwen3.8-27B.">
<meta property="og:url" content="https://self-context.github.io/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents">
<meta name="twitter:description" content="Drop-in inference-time working graph and reversible whole-turn history folding for long-horizon LLM agents.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@300..800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Literata:ital,opsz,wght@0,7..72,400..600;1,7..72,400..600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Google+Sans+Code:ital,wght@0,300..700;1,300..700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="static/css/main.css">
<script src="static/js/tooltips.js"></script>
<script>
(function () {
var t = localStorage.getItem('theme') ||
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', t);
var qp = null;
try { qp = new URLSearchParams(location.search).get('lang'); } catch (e) {}
var lg = (qp === 'zh' || qp === 'en') ? qp : (localStorage.getItem('lang') || 'en');
document.documentElement.setAttribute('data-lang', lg);
document.documentElement.setAttribute('lang', lg === 'zh' ? 'zh-CN' : 'en');
})();
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ScholarlyArticle",
"name": "Self-Context",
"headline": "Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents",
"url": "https://self-context.github.io/",
"sameAs": "https://arxiv.org/abs/2612.01681",
"codeRepository": "https://github.com/XMUDeepLIT/Self-Context",
"author": [
{"@type":"Person","name":"Ziheng Wang"},
{"@type":"Person","name":"Chengyi Yang"},
{"@type":"Person","name":"Renxu Bao"},
{"@type":"Person","name":"Zhishang Xiang"},
{"@type":"Person","name":"Chengsong Huang"},
{"@type":"Person","name":"Wenhao Li"},
{"@type":"Person","name":"Junnan Zhu"},
{"@type":"Person","name":"Delai Qiu"},
{"@type":"Person","name":"Yining Wang"},
{"@type":"Person","name":"Shengping Liu"},
{"@type":"Person","name":"Jinsong Su"}
]
}
</script>
</head>
<body>
<!-- ============ HUD NAV ============ -->
<header class="hud" id="hud">
<div class="hud-in">
<a class="wordmark" href="#top">
<img class="mark" src="static/images/favicon.svg" alt="" width="22" height="22">
Self-Context
</a>
<nav class="hud-nav" aria-label="Primary navigation">
<a href="#idea" class="hide-s" data-i18n="nav_idea">Idea</a>
<a href="#play" data-i18n="nav_play">Playground</a>
<a href="#architecture" class="hide-s" data-i18n="nav_arch">Architecture</a>
<a href="#results" data-i18n="nav_res">Results</a>
<a href="#discussion" class="hide-m" data-i18n="nav_disc">Discussion</a>
<a href="#gateway" class="hide-m" data-i18n="nav_gw">Gateway</a>
<a href="#cite" class="hide-s" data-i18n="nav_cite">Cite</a>
<a href="https://arxiv.org/abs/2612.01681" class="navbtn" target="_blank" rel="noopener" data-i18n="nav_paper">Paper ↗</a>
<a href="https://github.com/XMUDeepLIT/Self-Context" class="navbtn hide-s" target="_blank" rel="noopener" data-i18n="nav_code">Code ↗</a>
<button class="tbtn lang-btn" id="langBtn" type="button" aria-label="Switch language">中文</button>
<button class="tbtn" id="themeBtn" type="button" aria-label="Toggle color theme">Dark</button>
</nav>
</div>
<nav class="mob-nav" aria-label="Mobile section links">
<a href="#idea" data-i18n="mnav_idea">01 Idea</a>
<a href="#play" data-i18n="mnav_play">02 Playground</a>
<a href="#architecture" data-i18n="mnav_arch">03 Architecture</a>
<a href="#results" data-i18n="mnav_res">04 Results</a>
<a href="#discussion" data-i18n="mnav_disc">05 Discussion</a>
<a href="#gateway" data-i18n="mnav_gw">06 Gateway</a>
<a href="#cite" data-i18n="mnav_cite">07 Cite</a>
<a href="https://github.com/XMUDeepLIT/Self-Context" target="_blank" rel="noopener" data-i18n="nav_code">Code ↗</a>
</nav>
</header>
<main>
<!-- ============ HERO ============ -->
<section class="hero" id="top">
<div class="hero-in">
<div class="eyebrow" data-i18n="hero_eyebrow"><b>Inference-Time Context Gateway</b> · Zero Retraining · Unchanged Harnesses</div>
<h1 class="papertitle" data-i18n="hero_title"><span class="grad">Self-Context</span>: Graph-Based Context Self-Management for Long-Horizon Agents</h1>
<p class="authors">
<b>Ziheng Wang<sup>1,2*</sup></b>, <b>Chengyi Yang<sup>1,2†*</sup></b>,
<b>Renxu Bao<sup>1,2*</sup></b>, <b>Zhishang Xiang<sup>1,2</sup></b>,
<b>Chengsong Huang<sup>4</sup></b>, <b>Wenhao Li<sup>5</sup></b>,
<b>Junnan Zhu<sup>6</sup></b>, <b>Delai Qiu<sup>3</sup></b>,
<b>Yining Wang<sup>3</sup></b>, <b>Shengping Liu<sup>3</sup></b> and
<b>Jinsong Su<sup>1,2‡</sup></b>
</p>
<p class="affils" data-i18n="hero_affils">
<sup>1</sup>Xiamen University ·
<sup>2</sup>Key Lab of Digital Protection and Intelligent Processing of Intangible Cultural Heritage of Fujian-Taiwan (XMU)<br>
<sup>3</sup>Unisound ·
<sup>4</sup>Washington University in St. Louis ·
<sup>5</sup>Nanyang Technological University ·
<sup>6</sup>Institute of Automation, Chinese Academy of Sciences
</p>
<p class="fnotes" data-i18n="hero_fnotes">
<sup>*</sup>Equal contributions · <sup>†</sup>Project leader · <sup>‡</sup>Corresponding author
</p>
<p class="tagline" data-i18n="hero_tagline">Harnesses stuff the prompt. <span class="grad">Self-Context lets the model curate it.</span></p>
<div class="cta">
<a class="btn-hero primary" href="#play" data-i18n="cta_play">▶ Curate the context yourself</a>
<a class="btn-hero" href="https://arxiv.org/abs/2612.01681" target="_blank" rel="noopener">
<svg class="bicon" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M4 0h5.5L14 4.5V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1Zm5 1.5V5h3.5L9 1.5ZM5.5 8h5a.75.75 0 0 1 0 1.5h-5a.75.75 0 0 1 0-1.5Zm0 3h5a.75.75 0 0 1 0 1.5h-5a.75.75 0 0 1 0-1.5Z"/></svg>
<span data-i18n="cta_paper">Paper</span>
</a>
<a class="btn-hero" href="https://huggingface.co/papers/2612.01681" target="_blank" rel="noopener">
<span aria-hidden="true" style="font-size:14px;line-height:1">🤗</span>
<span data-i18n="cta_hf">HF Paper</span>
</a>
<a class="btn-hero" href="https://github.com/XMUDeepLIT/Self-Context" target="_blank" rel="noopener">
<svg class="bicon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0 0 22 12.017C22 6.484 17.522 2 12 2Z"/></svg>
<span data-i18n="cta_code">Code</span>
</a>
<a class="btn-hero" href="#architecture">
<svg class="bicon" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M2 2.5A1.5 1.5 0 0 1 3.5 1h3A1.5 1.5 0 0 1 8 2.5v3A1.5 1.5 0 0 1 6.5 7h-3A1.5 1.5 0 0 1 2 5.5v-3Zm6 8A1.5 1.5 0 0 1 9.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 8 13.5v-3ZM6.5 4h2A2.5 2.5 0 0 1 11 6.5V9h-1.5V6.5a1 1 0 0 0-1-1h-2V4Z"/></svg>
<span data-i18n="cta_arch">Architecture & Replay</span>
</a>
</div>
<!-- Dual Interactive Showcase -->
<div class="herofigs">
<div class="vpanel heropanel" id="heroBars">
<div class="vtitle" data-i18n="hb_title">Long-Horizon Performance · Three Benchmarks (Qwen3.8-27B)</div>
<div class="vchart">
<div class="vgroup">
<div class="vplot">
<div class="vcol a" data-h="47"
data-tip="Context-Folding (Best Prior)|55.3 ± 0.9% accuracy · 22.2 mean turns"
data-tip-zh="Context-Folding(最优已有方法)|准确率 55.3 ± 0.9% · 平均 22.2 轮"><span class="vval">55.3</span><i class="vfill"></i></div>
<div class="vcol b" data-h="45"
data-tip="Vanilla Harness|53.1 ± 1.8% accuracy · 14.5 mean turns"
data-tip-zh="Vanilla Harness(原生基线)|准确率 53.1 ± 1.8% · 平均 14.5 轮"><span class="vval">53.1</span><i class="vfill"></i></div>
<div class="vcol c" data-h="49"
data-tip="Self-Context (Ours)|57.3 ± 0.3% accuracy (+4.2 pp over Vanilla Harness)"
data-tip-zh="Self-Context(本文方法)|准确率 57.3 ± 0.3%(较原生基线 +4.2 pp)"><span class="vval">57.3</span><span class="vdelta">↑ +4.2</span><i class="vfill"></i></div>
</div>
<div class="vglab">BrowseComp-Plus</div>
</div>
<div class="vgroup">
<div class="vplot">
<div class="vcol a" data-h="56"
data-tip="ACM (Best Prior)|65.9 ± 3.9% success · 48.1 mean turns"
data-tip-zh="ACM(最优已有方法)|成功率 65.9 ± 3.9% · 平均 48.1 轮"><span class="vval">65.9</span><i class="vfill"></i></div>
<div class="vcol b" data-h="63"
data-tip="Vanilla Harness|74.2 ± 1.1% success · 49.3 mean turns"
data-tip-zh="Vanilla Harness(原生基线)|成功率 74.2 ± 1.1% · 平均 49.3 轮"><span class="vval">74.2</span><i class="vfill"></i></div>
<div class="vcol c" data-h="70"
data-tip="Self-Context (Ours)|82.0 ± 1.9% success (+7.8 pp, 31.8% fewer turns)"
data-tip-zh="Self-Context(本文方法)|成功率 82.0 ± 1.9%(+7.8 pp,轮次减少 31.8%)"><span class="vval">82.0</span><span class="vdelta">↑ +7.8</span><i class="vfill"></i></div>
</div>
<div class="vglab">Terminal-Bench 2.1</div>
</div>
<div class="vgroup">
<div class="vplot">
<div class="vcol a" data-h="59"
data-tip="ACM (Best Prior)|69.7 ± 1.6% score · 23.4 mean turns"
data-tip-zh="ACM(最优已有方法)|得分 69.7 ± 1.6% · 平均 23.4 轮"><span class="vval">69.7</span><i class="vfill"></i></div>
<div class="vcol b" data-h="55"
data-tip="Vanilla Harness|65.0 ± 1.1% score · 17.1 mean turns"
data-tip-zh="Vanilla Harness(原生基线)|得分 65.0 ± 1.1% · 平均 17.1 轮"><span class="vval">65.0</span><i class="vfill"></i></div>
<div class="vcol c" data-h="60"
data-tip="Self-Context (Ours)|70.2 ± 1.4% score (+5.2 pp, 25.1% fewer turns)"
data-tip-zh="Self-Context(本文方法)|得分 70.2 ± 1.4%(+5.2 pp,轮次减少 25.1%)"><span class="vval">70.2</span><span class="vdelta">↑ +5.2</span><i class="vfill"></i></div>
</div>
<div class="vglab">QwenClawBench v1.1</div>
</div>
</div>
<div class="legend">
<span data-i18n="hb_leg_a"><i class="sw swa"></i>Best prior context method</span>
<span data-i18n="hb_leg_b"><i class="sw swb"></i>Vanilla Harness</span>
<span data-i18n="hb_leg_c"><i class="sw swc"></i>Self-Context (Ours)</span>
</div>
</div>
<div class="vpanel heropanel lpanel">
<div class="vtitle" data-i18n="lc_title">Cumulative Success vs. Turn Budget · Terminal-Bench 2.1</div>
<svg class="lchart" id="lchart" role="img"
aria-label="Cumulative task success rate on Terminal-Bench 2.1 with Qwen3.8-27B against agent turns. Self-Context matches Vanilla Harness's final 74.2% success by turn 61 and reaches 82.0%, while Vanilla Harness reaches 74.2% at turn 100 and ACM reaches 65.9%."></svg>
<p class="lfoot" data-i18n="lc_foot"><b>Faster convergence:</b> Self-Context reaches Vanilla Harness’s final <b>74.2%</b> success by <b>turn 61</b> (vs. turn 100) and finishes at <b>82.0%</b> in <b>33.6</b> mean turns.</p>
</div>
</div>
<!-- 15s Bilingual Pure-Performance Showcase Reel (Remotion H.264 MP4) -->
<div class="vpanel vid-panel" id="showcasePanel">
<div class="vid-head">
<div class="vtitle" style="margin-bottom:0" data-i18n="vid_title">15s Performance Overview · 9-Method Leaderboard, 6/6 Gains & Convergence</div>
<a class="vid-dl" id="showcaseLink" href="static/media/showcase_en.mp4" target="_blank" rel="noopener" data-i18n="vid_dl">HD MP4 ↗</a>
</div>
<div class="vid-frame">
<video id="showcaseVideo" src="static/media/showcase_en.mp4" autoplay loop muted playsinline preload="metadata"
aria-label="Self-Context 15-second benchmark performance showcase"></video>
</div>
</div>
</div>
</section>
<!-- ============ 01 · THE IDEA ============ -->
<section class="sec" id="idea">
<div class="sec-head rv">
<span class="secno" data-i18n="s1_no">01 · The Idea</span>
<h2 data-i18n="s1_h2">Curating context from the inside, without losing raw history</h2>
<p class="lead" data-i18n="s1_lead">Long-horizon agents face two core context bottlenecks: <b>accumulating context noise</b> as verbose shell logs, superseded hypotheses, and distractor documents crowd the window, and <b>irreversible context compaction</b> when external summarization discards raw evidence that later turns need again. <b>Self-Context</b> is a graph-based plug-and-play context self-management framework between a frozen LLM and its native harness, assembling <code>c_t = F_t ⊕ G_t</code> on every turn via <b>history management</b> <code>𝒯</code> (reversible whole-turn <code>fold</code> / <code>unfold</code> yielding critical history <code>F_t</code>) and <b>graph management</b> <code>𝒢</code> (an editable working graph <code>G_t</code>).</p>
</div>
<div class="anal rv" aria-label="Comparison between conventional context harnesses and Self-Context">
<div class="agrid ahead">
<div class="ah l"><span data-i18n="s1_ahl">Conventional Harnesses</span><i class="dot"></i></div>
<div class="ah r"><i class="dot"></i><span>Self-Context</span><span class="ours" data-i18n="s1_ours">ours</span></div>
</div>
<div class="agrid arow">
<span class="akey" data-i18n="s1_k1">context state</span>
<span class="aval l" data-i18n="s1_l1">direct accumulation or <b>irreversible compaction</b></span>
<span class="aval r" data-i18n="s1_r1"><b>critical history <code>F_t</code></b> ⊕ editable <b>working graph <code>G_t</code></b></span>
</div>
<div class="agrid arow">
<span class="akey" data-i18n="s1_k2">reversibility</span>
<span class="aval l" data-i18n="s1_l2">context noise buildup or permanently lost clues</span>
<span class="aval r" data-i18n="s1_r2"><b>selective <code>unfold</code></b> from lossless native history <code>H_t</code></span>
</div>
<div class="agrid arow">
<span class="akey" data-i18n="s1_k3">control locus</span>
<span class="aval l" data-i18n="s1_l3">fixed external heuristics or auxiliary summarizer calls</span>
<span class="aval r" data-i18n="s1_r3"><b>intrinsic XML <code><graph></code> ops</b> (<code>𝒯</code> & <code>𝒢</code>) emitted by actor</span>
</div>
<div class="agrid arow">
<span class="akey" data-i18n="s1_k4">integration</span>
<span class="aval l" data-i18n="s1_l4">entangled with custom agent loops & tool schemas</span>
<span class="aval r" data-i18n="s1_r4"><b>plug-and-play HTTP gateway</b> (OpenAI & Anthropic wire)</span>
</div>
<div class="agrid arow aout">
<span class="akey">Qwen3.8-27B</span>
<span class="aval l" data-i18n="s1_l5">64.1% macro avg · 27.0 mean turns</span>
<span class="aval r" data-i18n="s1_r5">69.8% macro avg (+5.7 pp) · 20.6 mean turns (−23.7%)</span>
</div>
</div>
<figure class="paper-fig rv">
<div class="img-sheet">
<img src="static/images/intro.png" alt="Paper Figure 1 contrasting direct accumulation (Vanilla Harness), irreversible context compaction, and Self-Context on a long-horizon episode." loading="lazy">
</div>
<figcaption data-i18n="s1_fig1">
<span class="fnum">Figure 1</span>
<b>Overcoming accumulating context noise and irreversible context compaction.</b> Direct accumulation floods the window with distractors; irreversible compaction overwrites subtle clues; <b>Self-Context</b> curates verified findings and subgoals in working graph <code>G_t</code> while keeping folded turns losslessly recoverable from native history <code>H_t</code>.
</figcaption>
</figure>
</section>
<!-- ============ 02 · PLAYGROUND ============ -->
<section class="sec" id="play">
<div class="sec-head rv">
<span class="secno" data-i18n="s2_no">02 · Playground</span>
<h2 data-i18n="s2_h2">Try <code>c_t = F_t ⊕ G_t</code> in your browser</h2>
<p class="lead" data-i18n="s2_lead">Inspect a multi-turn search episode (<i>“Which river runs through Mira Vale’s birthplace?”</i>). Click any turn card on the left to toggle <b>whole-turn Fold / Unfold</b>, or edit and apply a <code><graph></code> XML block on the right. Compare the model-facing context <code>c_t</code> against the untouched native history <code>H_t</code>.</p>
</div>
<div class="rv">
<div class="boot" id="pgBoot">
<span data-i18n="pg_boot">● Self-Context Engine · live whole-turn simulator</span>
<div class="metrics">
<span><span data-i18n="pg_m_ct">Model context <code>c_t</code>:</span> <b id="pgCtChars">5,273</b> <span data-i18n="pg_chars">chars</span></span>
<span><span data-i18n="pg_m_ht">Native history <code>H_t</code>:</span> <b id="pgHtChars">12,384</b> <span data-i18n="pg_chars">chars</span></span>
<span><span data-i18n="pg_m_dl">Footprint delta:</span> <b id="pgDelta">−57.4%</b></span>
</div>
</div>
<div class="pg-grid">
<div class="panel">
<div class="phead">
<h5 data-i18n="pg_insp">Context Inspector · live</h5>
<span class="tag" id="pgBadge">5 active nodes · 1 turn folded</span>
</div>
<div class="dual">
<div class="view obs">
<div class="vhead">c_t = F_t ⊕ G_t <span class="badge2" data-i18n="pg_b_ct">model-facing context</span></div>
<div class="sublabel" data-i18n="pg_sub_ft">Critical History F_t (click a turn to fold / unfold)</div>
<div class="turn-list" id="pgFtList"></div>
<div class="sublabel" data-i18n="pg_sub_gt">Editable Working Graph G_t</div>
<div class="gnode-list" id="pgGraphList"></div>
</div>
<div class="view">
<div class="vhead"><span data-i18n="pg_vh_ht">Native History H_t</span> <span class="badge2" data-i18n="pg_b_ht">stored in harness</span></div>
<div class="sublabel" data-i18n="pg_sub_ht">Lossless Turn Trajectories (h_i, a_i, o_i)</div>
<div class="turn-list" id="pgHtList"></div>
<div class="ht-invariants">
<div class="sublabel" data-i18n="pg_inv_hd">Gateway Wire Invariants</div>
<div class="inv-box">
<div class="inv-row"><span data-i18n="pg_inv_1">Tool-call / result ID bijection</span><b class="ok" data-i18n="pg_inv_1v">3 / 3 paired ✓</b></div>
<div class="inv-row"><span data-i18n="pg_inv_2">Recoverable via <code>unfold</code></span><b id="pgRecoverable">100% (12,384 ch)</b></div>
<div class="inv-row"><span data-i18n="pg_inv_3">Harness tool-schema edits</span><b data-i18n="pg_inv_3v">0 (transparent)</b></div>
<div class="inv-row"><span data-i18n="pg_inv_4">Unfolded prefix cache</span><b class="ok" data-i18n="pg_inv_4v">append-stable</b></div>
</div>
</div>
</div>
</div>
<div class="verdict ok" id="pgVerdict">Turn 1 folded into a 1-line stub in F_t; raw 7,420-char biography stays intact in H_t.</div>
</div>
<div class="panel">
<div class="phead">
<h5 data-i18n="pg_xml_hd">Model <code><graph></code> Block</h5>
<span class="tag" data-i18n="pg_xml_tag">editable XML protocol</span>
</div>
<div class="tabs" id="pgTabs">
<button class="tab active" type="button" data-k="add" data-i18n="pg_t_add">Add Finding</button>
<button class="tab" type="button" data-k="fold" data-i18n="pg_t_fold">Fold Turn 2</button>
<button class="tab" type="button" data-k="edit" data-i18n="pg_t_edit">Revise Node</button>
<button class="tab" type="button" data-k="unfold" data-i18n="pg_t_unfold">Unfold Turn 1</button>
<button class="tab" type="button" data-k="remove" data-i18n="pg_t_rem">Prune Lead</button>
</div>
<textarea class="editor" id="pgEditor" spellcheck="false" aria-label="Editable XML graph operations"></textarea>
<div class="docline" id="pgDoc"></div>
<div class="toolbar">
<button class="btn primary" id="pgApply" type="button" data-i18n="pg_apply">▸ Apply to context</button>
<button class="btn" id="pgReset" type="button" data-i18n="pg_reset">↺ Reset episode</button>
<span class="status" id="pgStatus">ready</span>
</div>
<div class="stack-view" id="pgApplied"><span class="empty-stack">initial episode state</span></div>
</div>
</div>
</div>
</section>
<!-- ============ 03 · ARCHITECTURE & TRAJECTORIES ============ -->
<section class="sec" id="architecture">
<div class="sec-head rv">
<span class="secno" data-i18n="s3_no">03 · Architecture & Trajectories</span>
<h2 data-i18n="s3_h2">Step through the turn pipeline and real benchmark episodes</h2>
<p class="lead" data-i18n="s3_lead">Every turn passes through four deterministic stages inside the gateway: parsing <code><graph></code> operations from the model reply, delivering clean native tool calls to the harness, applying graph and fold updates, and reassembling <code>c_t = F_t ⊕ G_t</code>. Switch tabs below to inspect the animated architecture (<b>Figure 2</b>) or replay real BrowseComp-Plus episodes (<b>Figures 5 & 6</b>).</p>
</div>
<div class="stage-shell rv" id="stageShell">
<div class="stage-bar">
<div class="stage-tabs" role="tablist" aria-label="Interactive diagram selector">
<button class="stab" type="button" role="tab" aria-selected="true" data-stage="method" data-i18n="s3_tab_m">Figure 2 · Turn Pipeline</button>
<button class="stab" type="button" role="tab" aria-selected="false" data-stage="case88" data-i18n="s3_tab_88">Figure 5 · Task #88 (Fold & Unfold)</button>
<button class="stab" type="button" role="tab" aria-selected="false" data-stage="case764" data-i18n="s3_tab_764">Figure 6 · Task #764 (Graph vs. Baselines)</button>
</div>
<div class="stage-sub">
<div id="methodSub" style="display:flex;gap:5px;flex-wrap:wrap"></div>
<a class="ext-link" id="stageExtLink" href="method.html" target="_blank" rel="noopener" data-i18n="s3_full">Fullscreen ↗</a>
</div>
</div>
<div class="frame-wrap">
<iframe id="methodFrame" class="active" src="method.html?embed=1" title="Interactive Figure 2: Self-Context Architecture" loading="lazy"></iframe>
<iframe id="caseFrame" src="case-study.html?embed=1" title="Interactive Figures 5 and 6: Trajectory Case Studies"></iframe>
</div>
</div>
</section>
<!-- ============ 04 · RESULTS ============ -->
<section class="sec" id="results">
<div class="sec-head rv">
<span class="secno" data-i18n="s4_no">04 · Results</span>
<h2 data-i18n="s4_h2">Consistent gains across search, code, and working tasks</h2>
<p class="lead" data-i18n="s4_lead">Across <b>1,019 tasks</b> spanning BrowseComp-Plus (<b>830</b> search tasks), Terminal-Bench 2.1 (<b>89</b> code tasks), and QwenClawBench v1.1 (<b>100</b> working tasks), Self-Context achieves the highest macro-average score among all <b>nine evaluated methods</b> on both <b>Qwen3.8-27B</b> and <b>Qwen3.6-27B</b> while cutting interaction turns by up to <b>31.8%</b>.</p>
</div>
<div class="vpanel rv" id="barPanel">
<div class="res-controls">
<div>
<div class="vtitle" id="barKicker" style="margin-bottom:4px">Table 1 · Qwen3.8-27B · Macro Average (%)</div>
<div style="font-size:12.5px;color:var(--ink-3);font-family:var(--mono)" id="barAxisLbl" data-i18n="s4_axis">Mean across 3 runs · top label shows mean interaction turns</div>
</div>
<div style="display:flex;gap:8px;flex-wrap:wrap">
<div class="seg-group" role="group" aria-label="Backbone model">
<button class="seg-btn" type="button" data-model="qwen38" aria-pressed="true">Qwen3.8-27B</button>
<button class="seg-btn" type="button" data-model="qwen36" aria-pressed="false">Qwen3.6-27B</button>
</div>
<div class="seg-group" role="group" aria-label="Benchmark metric">
<button class="seg-btn" type="button" data-bench="macro" aria-pressed="true" data-i18n="s4_b_macro">Macro Avg</button>
<button class="seg-btn" type="button" data-bench="bcp" aria-pressed="false">BrowseComp+</button>
<button class="seg-btn" type="button" data-bench="tb21" aria-pressed="false">Terminal-Bench</button>
<button class="seg-btn" type="button" data-bench="qwenclaw" aria-pressed="false">QwenClaw</button>
</div>
</div>
</div>
<div class="bar-scroll">
<div class="bar-inner">
<div class="bhead" id="bhead"></div>
<div class="plot9" id="plot">
<svg class="arcs" id="arcs" aria-hidden="true"></svg>
</div>
</div>
</div>
<div class="tbl-toggle">
<div class="legend" style="margin-top:0">
<span data-i18n="s4_leg_a"><i class="sw swa"></i>Context compaction & self-management baselines</span>
<span data-i18n="s4_leg_b"><i class="sw swb"></i>Vanilla Harness</span>
<span data-i18n="s4_leg_c"><i class="sw swc"></i>Self-Context (Ours)</span>
</div>
<button class="btn" id="tableBtn" type="button" aria-expanded="false">View complete 18-row paper Table 1 ↓</button>
</div>
<div class="tbl-wrap" id="tables" hidden>
<table class="data-tbl">
<thead>
<tr>
<th data-i18n="th_model">Backbone</th>
<th data-i18n="th_method">Method</th>
<th class="n" data-i18n="th_bcp">Search: BCP (%)</th>
<th class="n" data-i18n="th_turns1">Turns</th>
<th class="n" data-i18n="th_tb">Code: TB 2.1 (%)</th>
<th class="n" data-i18n="th_turns2">Turns</th>
<th class="n" data-i18n="th_qc">Working: QwenClaw (%)</th>
<th class="n" data-i18n="th_turns3">Turns</th>
<th class="n" data-i18n="th_macro">Macro Avg. (%)</th>
<th class="n" data-i18n="th_mturns">Macro Turns</th>
</tr>
</thead>
<tbody id="fullTableBody"></tbody>
</table>
</div>
</div>
<!-- Component Ablations & Curation Mix -->
<div class="abl-grid rv">
<div class="vpanel" style="margin-top:0">
<div class="vtitle" data-i18n="abl_title">Table 2 · Component Ablations (Qwen3.8-27B Macro Avg.)</div>
<div class="abl-rows">
<div class="abl-r ours"
data-tip="Self-Context (𝒯 + 𝒢)|BCP 57.3% · TB 2.1 82.0% · QwenClaw 70.2% · 20.6 mean turns"
data-tip-zh="Self-Context(𝒯 + 𝒢)|BCP 57.3% · TB 2.1 82.0% · QwenClaw 70.2% · 平均 20.6 轮">
<div class="abl-lbl">Self-Context<small data-i18n="abl_s1">History 𝒯 + Working graph 𝒢</small></div>
<div class="abl-track"><div class="abl-fill" style="width:94%"></div></div>
<div class="abl-val">69.8%</div>
</div>
<div class="abl-r"
data-tip="w/o 𝒯 (Without History Management)|BCP 56.7% · TB 2.1 68.9% (-13.1 pp) · QwenClaw 66.4% · 26.8 turns"
data-tip-zh="w/o 𝒯(不含历史管理)|BCP 56.7% · TB 2.1 68.9%(−13.1 pp)· QwenClaw 66.4% · 26.8 轮">
<div class="abl-lbl">w/o 𝒯<small data-i18n="abl_s2">Without history management</small></div>
<div class="abl-track"><div class="abl-fill" style="width:82%"></div></div>
<div class="abl-val">64.0%</div>
</div>
<div class="abl-r"
data-tip="w/o 𝒢 (Without Graph Management)|BCP 48.5% (-8.8 pp) · TB 2.1 68.9% · QwenClaw 66.3% · 25.8 turns"
data-tip-zh="w/o 𝒢(不含图管理)|BCP 48.5%(−8.8 pp)· TB 2.1 68.9% · QwenClaw 66.3% · 25.8 轮">
<div class="abl-lbl">w/o 𝒢<small data-i18n="abl_s3">Without graph management</small></div>
<div class="abl-track"><div class="abl-fill" style="width:76%"></div></div>
<div class="abl-val">61.2%</div>
</div>
<div class="abl-r"
data-tip="w/o 𝒯 and 𝒢 (Retaining XML <commit>)|BCP 41.0% · TB 2.1 76.4% · QwenClaw 55.5% · 35.0 turns"
data-tip-zh="w/o 𝒯 and 𝒢(仅保留 XML <commit>)|BCP 41.0% · TB 2.1 76.4% · QwenClaw 55.5% · 35.0 轮">
<div class="abl-lbl">w/o 𝒯 and 𝒢<small data-i18n="abl_s4">XML <commit> without state curation</small></div>
<div class="abl-track"><div class="abl-fill" style="width:68%"></div></div>
<div class="abl-val">57.6%</div>
</div>
</div>
<p class="figcap" style="margin-top:16px" data-i18n="abl_cap"><b>Complementary components:</b> removing history management (<code>w/o 𝒯</code>) drops Terminal-Bench 2.1 by <b>13.1 pp</b> (82.0% → 68.9%), while removing graph management (<code>w/o 𝒢</code>) drops BrowseComp-Plus by <b>8.8 pp</b> (57.3% → 48.5%).</p>
</div>
<div class="vpanel" style="margin-top:0">
<div class="vtitle" data-i18n="op_title">Figure 4 · Intrinsic Curation (255,208 Recorded Operations)</div>
<div class="op-bars">
<div class="op-row"
data-tip="add · 107,571 operations (42.2%)|Creates goal, subgoal, finding, hypothesis, plan, and answer nodes"
data-tip-zh="add · 107,571 次操作(42.2%)|创建 goal、subgoal、finding、hypothesis、plan 与 answer 节点"><span>add</span><div class="op-bar"><i style="width:84.4%"></i></div><span style="text-align:right">42.2%</span></div>
<div class="op-row"
data-tip="remove · 94,441 operations (37.0%)|Prunes disproved hypotheses and completed plans (0.88× remove-to-add)"
data-tip-zh="remove · 94,441 次操作(37.0%)|剪枝被证伪的假设与已完成的计划(0.88× 删增比)"><span>remove</span><div class="op-bar prn"><i style="width:74.0%"></i></div><span style="text-align:right">37.0%</span></div>
<div class="op-row"
data-tip="edit · 44,863 operations (17.6%)|Revises existing node content or status in place"
data-tip-zh="edit · 44,863 次操作(17.6%)|原地修订已有节点的内容或状态"><span>edit</span><div class="op-bar rev"><i style="width:35.2%"></i></div><span style="text-align:right">17.6%</span></div>
<div class="op-row"
data-tip="fold / link / unfold · 8,333 operations (3.3%)|8,329 whole-turn folds plus selective graph links & unfolds"
data-tip-zh="fold / link / unfold · 8,333 次操作(3.3%)|8,329 次整轮折叠以及按需连边与展开"><span>fold</span><div class="op-bar rev"><i style="width:9.5%"></i></div><span style="text-align:right">3.3%</span></div>
</div>
<p class="figcap" style="margin-top:18px" data-i18n="op_cap"><b>Active pruning, not append-only notes:</b> the ratio of <code>remove</code> to <code>add</code> is <b>0.88×</b> (94,441 vs. 107,571), and <b>17.6%</b> of operations revise existing nodes in place via <code>edit</code>.</p>
</div>
</div>
<!-- EnvHarness-style "Also in the paper" 4-column box -->
<div class="morep rv">
<h4 data-i18n="mp_h4">Also in the paper</h4>
<div class="mrow4">
<div class="mitem">
<b data-i18n="mp_1b">Turn 61 vs. 100</b>
<span data-i18n="mp_1s">On Terminal-Bench 2.1, Self-Context matches Vanilla Harness’s final 74.2% success in 61 turns (vs. 100), and in 19 vs. 27 turns on BrowseComp-Plus and 22 vs. 139 on QwenClawBench v1.1.</span>
</div>
<div class="mitem">
<b data-i18n="mp_2b">0.88× Remove / Add</b>
<span data-i18n="mp_2s">Nodes leave the working graph nearly as fast as they enter. Revision operations (<code>edit</code>, <code>remove</code>, <code>link</code>) make up 43.4%, 41.7%, and 30.6% of all graph ops across search, code, and working tasks.</span>
</div>
<div class="mitem">
<b data-i18n="mp_3b">−30.6% Shell Execs</b>
<span data-i18n="mp_3s">With Qwen3.8-27B, Self-Context cuts redundant shell executions by 30.6% on Terminal-Bench 2.1 and document reads by 19.8% on BrowseComp-Plus while raising task accuracy.</span>
</div>
<div class="mitem">
<b data-i18n="mp_4b">2× Findings / Hyp.</b>
<span data-i18n="mp_4s">Recovered graphs decompose each Goal into 2.2–3.6 Subgoals and pair Hypothesis nodes (16.1%) with roughly twice as many Finding nodes (32.6%) for hypothesis-driven exploration.</span>
</div>
</div>
<p class="mfoot" data-i18n="mp_foot">Every experiment uses unmodified native benchmark harnesses and identical actor sampling parameters across three independent runs.</p>
</div>
</section>
<!-- ============ 05 · DISCUSSION ============ -->
<section class="sec" id="discussion">
<div class="sec-head rv">
<span class="secno" data-i18n="s5_no">05 · Discussion</span>
<h2 data-i18n="s5_h2">Why intrinsic, reversible self-management beats external compaction</h2>
</div>
<div class="disc-grid rv">
<div class="take">
<p data-i18n="s5_p1"><b>External compaction guesses what future turns will need; the actor already knows.</b> Dedicated compaction baselines often fall below Vanilla Harness in macro average (e.g., 62.9% for ACM and 57.7% for CLM vs. 64.1% for Vanilla Harness on Qwen3.8-27B) because periodic summarization and hard resets sever the link between candidate hypotheses, rejected distractors, and exact tool identifiers.</p>
<p data-i18n="s5_p2"><b>History management <code>𝒯</code> and graph management <code>𝒢</code> target complementary bottlenecks.</b> In code tasks, verbose shell traces flood the prompt; whole-turn <code>fold</code> collapses completed turns into compact stubs while preserving 1-to-1 tool-call/result pairing in <code>H_t</code> so <code>unfold</code> can recover exact tracebacks on demand. In multi-hop search, the editable working graph <code>G_t</code> prevents cyclic re-queries by linking disproved candidates and verified findings under explicit subgoals.</p>
</div>
<aside class="scope-card" aria-label="Domain breakdown and scope">
<h4 data-i18n="s5_sh4">Where Each Component Contributes</h4>
<div class="scope-list">
<div class="scope-item" data-i18n="s5_si1">
<b>Search · BrowseComp-Plus (+4.2 / +5.7 pp)</b>
Editable working graph <code>G_t</code> tracks verified <code>finding</code> and rejected <code>hypothesis</code> nodes across 830 multi-hop queries.
</div>
<div class="scope-item" data-i18n="s5_si2">
<b>Code · Terminal-Bench 2.1 (+7.8 pp, −31.8% turns)</b>
Whole-turn <code>fold</code> sheds bulky build and test logs while keeping raw lines losslessly reopenable via <code>unfold</code>.
</div>
<div class="scope-item" data-i18n="s5_si3">
<b>Working · QwenClawBench v1.1 (+5.2 pp, −25.1% turns)</b>
Joint <code>F_t ⊕ G_t</code> curation coordinates multi-file workspace deliverables in OpenClaw without harness edits.
</div>
<div class="scope-item" data-i18n="s5_si4">
<b>Inference-Time Scope</b>
Evaluated zero-shot on frozen open-weight LLMs; end-to-end RL over <code>𝒯</code> and <code>𝒢</code> is left for future work.
</div>
</div>
</aside>
</div>
</section>
<!-- ============ 06 · GATEWAY & CODE ============ -->
<section class="sec" id="gateway">
<div class="sec-head rv">
<span class="secno" data-i18n="s6_no">06 · Gateway & Code</span>
<h2 data-i18n="s6_h2">Drop into your existing OpenAI or Anthropic agent in two lines</h2>
<p class="lead" data-i18n="s6_lead">Keep your native harness, tool definitions, and container sandbox unchanged. Point your SDK’s <code>base_url</code> at <code>self-context-gateway</code>, or run the dependency-free scripted demo offline in seconds.</p>
</div>
<div class="code-grid rv">
<div class="code-card">
<div class="phead"><h5 data-i18n="s6_c1h">1 · Offline Demo & CLI Gateway</h5><span class="tag">POSIX / Python 3.12 + uv</span></div>
<pre><code data-i18n="s6_c1b">git clone https://github.com/XMUDeepLIT/Self-Context.git
cd Self-Context && uv sync --locked
# Run offline mechanism demo (no API key or GPU needed)
uv run --no-sync python quick_start.py
# Or launch the drop-in HTTP gateway in front of vLLM / SGLang
uv run --no-sync self-context-gateway \
--upstream http://127.0.0.1:8000/v1 --model Qwen3.8-27B \
--provider openai --tokenizer /path/to/Qwen3.8-27B-FP8 \
--port 8700 --log-dir outputs/gateway</code></pre>
</div>
<div class="code-card">
<div class="phead"><h5 data-i18n="s6_c2h">2 · Python API & SDK Integration</h5><span class="tag" data-i18n="s6_c2t">OpenAI & Anthropic compatible</span></div>
<pre><code data-i18n="s6_c2b">from openai import OpenAI
from self_context import GatewayConfig, Graph, create_app
# Point any existing OpenAI / Anthropic harness at the gateway
client = OpenAI(
base_url="http://127.0.0.1:8700/v1",
api_key="EMPTY",
)
# Or mount the ASGI gateway directly in-process
app = create_app(GatewayConfig(
provider="openai",
base_url="http://127.0.0.1:8000/v1",
model="Qwen3.8-27B",
default_mode="self_context",
))</code></pre>
</div>
</div>
</section>
<!-- ============ 07 · CITE ============ -->
<section class="sec" id="cite">
<div class="sec-head rv">
<span class="secno" data-i18n="s7_no">07 · Citation</span>
<h2 data-i18n="s7_h2">Cite Self-Context</h2>
</div>
<div class="cite-grid rv">
<div class="bib-card" id="citationCard">
<div class="phead">
<h5>BibTeX · arXiv:2612.01681</h5>
<button class="btn copy-bib" id="citationCopy" type="button">Copy BibTeX</button>
</div>
<pre id="citationText">@misc{wang2026self-context,
title = {Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents},
author = {Ziheng Wang and Chengyi Yang and Renxu Bao and Zhishang Xiang and Chengsong Huang and Wenhao Li and Junnan Zhu and Delai Qiu and Yining Wang and Shengping Liu and Jinsong Su},
year = {2026},
eprint = {2612.01681},
archivePrefix = {arXiv},
primaryClass = {cs.AI},
url = {https://arxiv.org/abs/2612.01681}
}</pre>
</div>
<aside class="res-links-card" aria-label="Paper and code resources">
<div>
<h4 data-i18n="s7_rh4">Paper & Artifacts</h4>
<div class="rlink-list">
<a class="rlink" href="https://arxiv.org/abs/2612.01681" target="_blank" rel="noopener"><b data-i18n="s7_l1">arXiv Abstract</b><span>2612.01681 ↗</span></a>
<a class="rlink" href="https://huggingface.co/papers/2612.01681" target="_blank" rel="noopener"><b data-i18n="s7_l2">Hugging Face Paper</b><span>hf.co/papers ↗</span></a>
<a class="rlink" href="https://github.com/XMUDeepLIT/Self-Context" target="_blank" rel="noopener"><b data-i18n="s7_l3">Code & Benchmarks</b><span>Apache-2.0 ↗</span></a>
<a class="rlink" id="rlinkMethod" href="method.html" target="_blank" rel="noopener"><b data-i18n="s7_l4">Interactive Figure 2</b><span data-i18n="s7_ls">Standalone ↗</span></a>
<a class="rlink" id="rlinkCase" href="case-study.html" target="_blank" rel="noopener"><b data-i18n="s7_l5">Case Studies (#88 & #764)</b><span data-i18n="s7_ls">Standalone ↗</span></a>
</div>
</div>
<p class="cite-note" data-i18n="s7_note">Evaluated across 3 long-horizon domains (1,019 tasks, 9 context methods, 2 open-weight backbones).</p>
</aside>
</div>
</section>
</main>
<!-- ============ INSTITUTIONAL FOOTER (XMU & DeepLIT ONLY) ============ -->
<footer class="site-foot">
<div class="foot-in">
<div class="foot-top">
<div class="org-strip" aria-label="Affiliated research institutions">
<a class="org" href="https://en.xmu.edu.cn/" target="_blank" rel="noopener" data-org="Xiamen University" data-sub="厦门大学">
<img src="static/images/orgs/xmu.svg" alt="XMU" width="24" height="24" loading="lazy"> XMU
</a>
<a class="org" href="https://xmudeeplit.github.io/" target="_blank" rel="noopener" data-org="XMU-DeepLIT" data-sub="厦门大学语言智能技术课题组">
<img src="static/images/orgs/deeplit.png" alt="DeepLIT" width="24" height="24" loading="lazy"> DeepLIT
</a>
</div>
<nav class="foot-links" aria-label="Project links">
<a href="https://arxiv.org/abs/2612.01681" target="_blank" rel="noopener">arXiv:2612.01681</a>
<a href="https://huggingface.co/papers/2612.01681" target="_blank" rel="noopener" data-i18n="ft_hf">HF Paper</a>
<a href="https://github.com/XMUDeepLIT/Self-Context" target="_blank" rel="noopener" data-i18n="ft_gh">GitHub Repository</a>
<a id="footMethod" href="method.html" target="_blank" rel="noopener" data-i18n="ft_m">Standalone Figure 2</a>
<a id="footCase" href="case-study.html" target="_blank" rel="noopener" data-i18n="ft_c">Standalone Case Studies</a>
</nav>
</div>
<div class="foot-btm">
<span data-i18n="ft_copy">© 2026 Self-Context Contributors · Code released under Apache-2.0</span>
<span data-i18n="ft_orgs">XMU · DeepLIT</span>
</div>
</div>
</footer>
<div class="tip" id="tip" aria-hidden="true">
<button class="tip-close" type="button" aria-label="Close details">×</button>
<div class="tip-content" id="tip-content" role="status" aria-live="polite"></div>
</div>
<script>
(function () {
'use strict';
var REDUCED = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var NS = 'http://www.w3.org/2000/svg';
var BAR_SCALE = 116;
var curLang = document.documentElement.getAttribute('data-lang') === 'zh' ? 'zh' : 'en';
/* ── Bilingual Translation Dictionary (Simplified Chinese) ── */
var ZH = {
nav_idea: '核心思想', nav_play: '交互沙盒', nav_arch: '架构与轨迹', nav_res: '实验结果',
nav_disc: '深入讨论', nav_gw: '网关部署', nav_cite: '论文引用',
nav_paper: '论文 ↗', nav_code: '代码 ↗',
mnav_idea: '01 思想', mnav_play: '02 沙盒', mnav_arch: '03 架构', mnav_res: '04 结果',
mnav_disc: '05 讨论', mnav_gw: '06 网关', mnav_cite: '07 引用',
hero_eyebrow: '<b>推理期上下文网关</b> · 零参数重训 · 原生智能体框架零改动',
hero_title: '<span class="grad">Self-Context</span>:面向长程智能体的图结构上下文自管理框架',
hero_affils: '<sup>1</sup>厦门大学 · <sup>2</sup>文化和旅游部闽台非物质文化遗产数字化保护与智能处理重点实验室(厦门大学)<br><sup>3</sup>云知声 · <sup>4</sup>圣路易斯华盛顿大学 · <sup>5</sup>南洋理工大学 · <sup>6</sup>中国科学院自动化研究所',
hero_fnotes: '<sup>*</sup>共同第一作者 · <sup>†</sup>项目负责人 · <sup>‡</sup>通讯作者',
hero_tagline: '传统框架向提示词堆砌历史,<span class="grad">Self-Context 让模型自主策展上下文。</span>',
cta_play: '▶ 亲手体验上下文策展', cta_paper: '论文原文', cta_hf: 'HF 论文页',
cta_code: '开源代码', cta_arch: '架构与轨迹回放',
hb_title: '长程任务综合表现 · 三大基准评测 (Qwen3.8-27B)',
hb_leg_a: '<i class="sw swa"></i>最优已有上下文方法',
hb_leg_b: '<i class="sw swb"></i>Vanilla Harness(原生基线)',
hb_leg_c: '<i class="sw swc"></i>Self-Context(本文方法)',
lc_title: '随轮次预算变化的累计成功率 · Terminal-Bench 2.1',
lc_foot: '<b>更快收敛:</b>Self-Context 在<b>第 61 轮</b>即追平 Vanilla Harness 最终 <b>74.2%</b> 的成功率(后者需 100 轮),并以平均 <b>33.6</b> 轮达到 <b>82.0%</b>。',
vid_title: '15 秒纯性能总览动画 · 九方法总榜、双模型全胜与收敛曲线',
vid_dl: '高清 MP4 ↗',
s1_no: '01 · 核心思想',
s1_h2: '由智能体从内部自主策展上下文,且不丢失任何原始历史',
s1_lead: '长程智能体面临两大核心上下文瓶颈:一是随着冗长终端日志、失效假设与干扰文档不断涌入而产生的<b>累积上下文噪声</b>;二是外部摘要重写丢弃后续轮次仍需核对的原始证据所导致的<b>不可逆上下文压缩</b>。<b>Self-Context</b> 是位于冻结大模型与其原生智能体框架之间的即插即用图结构上下文自管理框架,在每一轮通过<b>历史管理</b> <code>𝒯</code>(整轮可逆 <code>fold</code> / <code>unfold</code>,生成关键历史 <code>F_t</code>)与<b>图管理</b> <code>𝒢</code>(可编辑工作图 <code>G_t</code>)组装模型输入 <code>c_t = F_t ⊕ G_t</code>。',
s1_ahl: '传统上下文框架', s1_ours: '本文',
s1_k1: '上下文状态', s1_l1: '直接拼接堆砌或<b>不可逆摘要压缩</b>', s1_r1: '<b>关键历史 <code>F_t</code></b> ⊕ 可编辑<b>工作图 <code>G_t</code></b>',
s1_k2: '可逆性', s1_l2: '噪声持续堆积,或细微线索永久丢失', s1_r2: '从无损原生历史 <code>H_t</code> <b>按需选择性 <code>unfold</code></b>',
s1_k3: '控制主体', s1_l3: '固定外部启发式规则或额外摘要模型调用', s1_r3: '由策略模型内生输出的 <b>XML <code><graph></code> 指令</b>(<code>𝒯</code> 与 <code>𝒢</code>)',
s1_k4: '接入方式', s1_l4: '与特定智能体循环和工具定义深度耦合', s1_r4: '<b>即插即用 HTTP 网关</b>(兼容 OpenAI 与 Anthropic 协议)',
s1_l5: '64.1% 宏平均 · 平均 27.0 轮', s1_r5: '69.8% 宏平均 (+5.7 pp) · 平均 20.6 轮 (−23.7%)',
s1_fig1: '<span class="fnum">图 1</span><b>同时克服累积上下文噪声与不可逆上下文压缩。</b>直接累积会让干扰信息淹没窗口;不可逆压缩会覆盖关键细节线索;<b>Self-Context</b> 在工作图 <code>G_t</code> 中沉淀已验证结论与子目标,同时保证被折叠轮次可随时从原生历史 <code>H_t</code> 无损恢复。',
s2_no: '02 · 交互沙盒',
s2_h2: '在浏览器中实时体验 <code>c_t = F_t ⊕ G_t</code>',
s2_lead: '检视一个多跳检索回合(<i>“哪条河流经 Mira Vale 的出生地?”</i>)。点击左侧任意轮次卡片切换<b>整轮折叠 / 展开(Fold / Unfold)</b>,或在右侧编辑并应用 <code><graph></code> XML 指令块,实时对比模型侧上下文 <code>c_t</code> 与无损保存的原生历史 <code>H_t</code>。',
pg_boot: '● Self-Context 引擎 · 整轮折叠实时模拟器',
pg_m_ct: '模型上下文 <code>c_t</code>:', pg_m_ht: '原生历史 <code>H_t</code>:', pg_m_dl: '体积变化:', pg_chars: '字符',
pg_insp: '上下文检视器 · 实时', pg_b_ct: '模型可见上下文',
pg_sub_ft: '关键历史 F_t(点击任意轮次切换折叠 / 展开)',
pg_sub_gt: '可编辑工作图 G_t',
pg_vh_ht: '原生历史 H_t', pg_b_ht: '框架侧完整保存',
pg_sub_ht: '无损单轮轨迹 (h_i, a_i, o_i)',
pg_inv_hd: '网关协议不变量',
pg_inv_1: '工具调用 / 返回 ID 双射配对', pg_inv_1v: '3 / 3 完整配对 ✓',
pg_inv_2: '可通过 <code>unfold</code> 无损恢复',
pg_inv_3: '原生工具 Schema 改动', pg_inv_3v: '0(完全透明)',
pg_inv_4: '未折叠前缀 KV 缓存', pg_inv_4v: '追加稳定',
pg_xml_hd: '模型输出 <code><graph></code> 指令块', pg_xml_tag: '可编辑 XML 协议',
pg_t_add: '新增结论', pg_t_fold: '折叠第 2 轮', pg_t_edit: '原地修订', pg_t_unfold: '展开第 1 轮', pg_t_rem: '剪枝干扰项',
pg_apply: '▸ 应用到上下文', pg_reset: '↺ 重置回合',
s3_no: '03 · 架构与真实轨迹',
s3_h2: '逐步拆解单轮网关流水线与真实评测轨迹',
s3_lead: '每一轮交互在网关内部依次经过四个确定性阶段:从模型回复中解析 <code><graph></code> 指令、向原生框架返回纯净工具调用、执行工作图与历史折叠更新,以及重新组装 <code>c_t = F_t ⊕ G_t</code>。切换下方标签可查看动态架构演示(<b>图 2</b>)或回放 BrowseComp-Plus 真实轨迹(<b>图 5 与图 6</b>)。',
s3_tab_m: '图 2 · 单轮流水线', s3_tab_88: '图 5 · 任务 #88(折叠与展开)', s3_tab_764: '图 6 · 任务 #764(工作图对比基线)',
s3_full: '全屏查看 ↗',
s4_no: '04 · 实验结果',
s4_h2: '在检索、代码与办公综合任务上取得一致提升',
s4_lead: '在涵盖 BrowseComp-Plus(<b>830</b> 个检索任务)、Terminal-Bench 2.1(<b>89</b> 个代码任务)与 QwenClawBench v1.1(<b>100</b> 个办公任务)共 <b>1,019 个任务</b>的评测中,Self-Context 在 <b>Qwen3.8-27B</b> 与 <b>Qwen3.6-27B</b> 两个基座上均取得全部<b>九种参评方法</b>中的最高宏平均得分,并将交互轮次最高缩减 <b>31.8%</b>。',
s4_axis: '3 次独立运行均值 · 顶部标签为平均交互轮次',
s4_b_macro: '宏平均',
s4_leg_a: '<i class="sw swa"></i>上下文压缩与自管理基线方法',
s4_leg_b: '<i class="sw swb"></i>Vanilla Harness(原生基线)',
s4_leg_c: '<i class="sw swc"></i>Self-Context(本文方法)',
th_model: '基座模型', th_method: '方法',
th_bcp: '检索: BCP (%)', th_turns1: '轮次',
th_tb: '代码: TB 2.1 (%)', th_turns2: '轮次',
th_qc: '办公: QwenClaw (%)', th_turns3: '轮次',
th_macro: '宏平均 (%)', th_mturns: '平均轮次',
abl_title: '表 2 · 模块消融实验(Qwen3.8-27B 宏平均)',
abl_s1: '历史管理 𝒯 + 工作图 𝒢', abl_s2: '去除历史管理模块', abl_s3: '去除工作图管理模块', abl_s4: '仅保留 XML <commit> 格式',
abl_cap: '<b>双模块互补增益:</b>去除历史管理(<code>w/o 𝒯</code>)会使 Terminal-Bench 2.1 下降 <b>13.1 pp</b>(82.0% → 68.9%);去除图管理(<code>w/o 𝒢</code>)会使 BrowseComp-Plus 下降 <b>8.8 pp</b>(57.3% → 48.5%)。',
op_title: '图 4 · 内生上下文策展分布(255,208 次记录操作)',
op_cap: '<b>主动剪枝而非只增不减:</b><code>remove</code> 与 <code>add</code> 的比例高达 <b>0.88×</b>(94,441 vs. 107,571),且 <b>17.6%</b> 的操作通过 <code>edit</code> 原地修订既有节点。',
mp_h4: '论文更多核心发现',
mp_1b: '61 轮 vs. 100 轮',
mp_1s: '在 Terminal-Bench 2.1 上,Self-Context 仅用 61 轮即追平 Vanilla Harness 第 100 轮的最终成功率(74.2%);在 BrowseComp-Plus 上为 19 轮 vs. 27 轮,在 QwenClawBench v1.1 上为 22 轮 vs. 139 轮。',
mp_2b: '0.88× 删增比',
mp_2s: '节点离开工作图的速度几乎与新增相当。修订类操作(<code>edit</code>、<code>remove</code>、<code>link</code>)在检索、代码和办公任务中分别占全部图操作的 43.4%、41.7% 与 30.6%。',
mp_3b: '−30.6% 终端执行',
mp_3s: '在 Qwen3.8-27B 上,Self-Context 将 Terminal-Bench 2.1 的冗余终端命令执行减少 30.6%,将 BrowseComp-Plus 的文档读取减少 19.8%,同时显著提升准确率。',
mp_4b: '2× 结论 / 假设比',
mp_4s: '恢复出的工作图平均将每个目标拆解为 2.2–3.6 个子目标,并以约 2 倍于假设节点(16.1%)的已验证结论节点(32.6%)支撑假设驱动式探索。',
mp_foot: '所有实验均使用未修改的原生评测框架,并在三次独立运行中保持完全一致的采样参数。',
s5_no: '05 · 深入讨论',
s5_h2: '为什么内生、可逆的自管理优于外部压缩?',
s5_p1: '<b>外部压缩只能猜测后续轮次需要什么,而策略模型自身最清楚当前推理脉络。</b>专用上下文压缩基线在宏平均上往往低于原生基线 Vanilla Harness(例如 Qwen3.8-27B 上 ACM 为 62.9%、CLM 为 57.7%,而 Vanilla Harness 为 64.1%),因为周期性摘要和硬重置会切断候选假设、已排除干扰项与精确工具标识符之间的关联。',
s5_p2: '<b>历史管理 <code>𝒯</code> 与图管理 <code>𝒢</code> 分别攻克互补瓶颈。</b>在代码任务中,冗长的终端输出极易淹没提示词;整轮 <code>fold</code> 将已完成轮次压缩为精简占位摘要,同时在 <code>H_t</code> 中保留工具调用与返回结果的 1 对 1 配对,使 <code>unfold</code> 可随时按需恢复完整报错栈。在多跳检索中,可编辑工作图 <code>G_t</code> 将已排除候选与已核实证据挂接在明确子目标下,避免循环重复检索。',
s5_sh4: '各模块在不同领域的作用',
s5_si1: '<b>多跳检索 · BrowseComp-Plus (+4.2 / +5.7 pp)</b>可编辑工作图 <code>G_t</code> 在 830 道多跳检索题中持续追踪已验证 <code>finding</code> 与已排除 <code>hypothesis</code> 节点。',
s5_si2: '<b>软件工程与终端 · Terminal-Bench 2.1 (+7.8 pp, −31.8% 轮次)</b>整轮 <code>fold</code> 卸下庞大的编译与测试日志,同时支持通过 <code>unfold</code> 无损重开任意原始行。',
s5_si3: '<b>交互式工具与办公 · QwenClawBench v1.1 (+5.2 pp, −25.1% 轮次)</b><code>F_t ⊕ G_t</code> 联合策展在不改动 OpenClaw 框架的前提下协调多文件交付。',
s5_si4: '<b>推理期适用边界</b>本文在冻结权重开源大模型上进行零样本评测;针对 <code>𝒯</code> 与 <code>𝒢</code> 的端到端强化学习留待后续探索。',
s6_no: '06 · 网关与代码',
s6_h2: '仅改两行配置,无缝接入现有 OpenAI 或 Anthropic 智能体',
s6_lead: '无需改动原生智能体循环、工具定义或容器沙盒。只需将 SDK 的 <code>base_url</code> 指向 <code>self-context-gateway</code>,或直接离线运行零外部依赖的机制演示脚本。',
s6_c1h: '1 · 离线演示与命令行网关',
s6_c1b: 'git clone https://github.com/XMUDeepLIT/Self-Context.git\ncd Self-Context && uv sync --locked\n\n# 离线运行机制演示(无需 API Key 或 GPU)\nuv run --no-sync python quick_start.py\n\n# 或在 vLLM / SGLang 前启动即插即用 HTTP 网关\nuv run --no-sync self-context-gateway \\\n --upstream http://127.0.0.1:8000/v1 --model Qwen3.8-27B \\\n --provider openai --tokenizer /path/to/Qwen3.8-27B-FP8 \\\n --port 8700 --log-dir outputs/gateway',
s6_c2h: '2 · Python API 与 SDK 集成', s6_c2t: '兼容 OpenAI 与 Anthropic',
s6_c2b: 'from openai import OpenAI\nfrom self_context import GatewayConfig, Graph, create_app\n\n# 将任意现有 OpenAI / Anthropic 智能体指向网关地址\nclient = OpenAI(\n base_url="http://127.0.0.1:8700/v1",\n api_key="EMPTY",\n)\n\n# 或在进程内直接挂载 ASGI 网关应用\napp = create_app(GatewayConfig(\n provider="openai",\n base_url="http://127.0.0.1:8000/v1",\n model="Qwen3.8-27B",\n default_mode="self_context",\n))',
s7_no: '07 · 论文引用', s7_h2: '引用 Self-Context',
s7_rh4: '论文与开源资源',
s7_l1: 'arXiv 论文页', s7_l2: 'Hugging Face 论文页', s7_l3: '代码与评测基准',
s7_l4: '交互式图 2 架构演示', s7_l5: '真实轨迹案例 (#88 & #764)', s7_ls: '独立页面 ↗',
s7_note: '横跨 3 大长程智能体领域评测(1,019 个任务、9 种上下文方法、2 个开源权重基座模型)。',
ft_hf: 'HF 论文页', ft_gh: 'GitHub 代码库', ft_m: '独立图 2 演示', ft_c: '独立案例回放',
ft_copy: '© 2026 Self-Context Contributors · 代码基于 Apache-2.0 协议开源',
ft_orgs: '厦门大学 · XMU-DeepLIT'
};
/* Cache original English innerHTML on every [data-i18n] node */
var i18nNodes = Array.prototype.slice.call(document.querySelectorAll('[data-i18n]'));
i18nNodes.forEach(function (el) { el._en = el.innerHTML; });
/* ── HUD Scroll State & Dynamic Sticky Offset ── */
var hud = document.getElementById('hud');
function syncHud() {
hud.classList.toggle('scrolled', window.scrollY > 12);
document.documentElement.style.setProperty('--hud-h', hud.offsetHeight + 'px');
}
syncHud();
window.addEventListener('scroll', syncHud, { passive: true });
window.addEventListener('resize', syncHud);
/* ── Theme Toggle with Circular View-Transition Wipe ── */
var themeBtn = document.getElementById('themeBtn');
function syncThemeBtn() {
var isDark = document.documentElement.getAttribute('data-theme') === 'dark';
themeBtn.textContent = curLang === 'zh' ? (isDark ? '浅色' : '深色') : (isDark ? 'Light' : 'Dark');
}
function applyTheme(next) {
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
syncThemeBtn();
['methodFrame', 'caseFrame'].forEach(function (id) {
var f = document.getElementById(id);
if (f && f.contentWindow) try { f.contentWindow.postMessage({ theme: next }, '*'); } catch (e) {}
});
}
var themeTr = null;
themeBtn.addEventListener('click', function () {
if (themeTr) return;
var next = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
if (REDUCED || !document.startViewTransition) { applyTheme(next); return; }
var r = themeBtn.getBoundingClientRect();
var x = r.left + r.width / 2, y = r.top + r.height / 2;
var far = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y));
var root = document.documentElement;
var tr = document.startViewTransition(function () { applyTheme(next); });
themeTr = tr;
function done() { themeTr = null; }
tr.finished.then(done, done);
tr.ready.then(function () {
root.animate(
{ clipPath: ['circle(0px at ' + x + 'px ' + y + 'px)', 'circle(' + far + 'px at ' + x + 'px ' + y + 'px)'] },
{ duration: 640, easing: 'cubic-bezier(.16, 1, .3, 1)', pseudoElement: '::view-transition-new(root)' }
);
}).catch(function () { tr.skipTransition(); });
});
/* ── Magnetic Hero CTAs ── */
if (!REDUCED) {
document.querySelectorAll('.btn-hero').forEach(function (b) {
b.addEventListener('mousemove', function (e) {
var r = b.getBoundingClientRect();
b.style.transform = 'translate(' + (((e.clientX - r.left) / r.width - .5) * 6).toFixed(1) + 'px,' +
(((e.clientY - r.top) / r.height - .5) * 5).toFixed(1) + 'px)';
});
b.addEventListener('mouseleave', function () { b.style.transform = ''; });
});
}
/* ── Scroll Reveal (.rv) — low threshold so tall mobile cards reveal immediately ── */
var ro = new IntersectionObserver(function (entries) {
entries.forEach(function (e) {
if (e.isIntersecting) { e.target.classList.add('in'); ro.unobserve(e.target); }
});
}, { threshold: 0.01, rootMargin: '0px 0px 32px 0px' });
document.querySelectorAll('.rv').forEach(function (el) { ro.observe(el); });
/* ── Hero Left Panel: Staggered Bars + Spring Delta Pills ── */
(function () {
var panel = document.getElementById('heroBars');
if (!panel) return;
var timers = [], seen = false, live = false;
function zero() {
timers.forEach(clearTimeout); timers = [];
panel.classList.add('noanim');
panel.querySelectorAll('.vcol').forEach(function (c) {
var f = c.querySelector('.vfill'), v = c.querySelector('.vval'), d = c.querySelector('.vdelta');
f.style.height = '0%'; v.style.bottom = '8px'; v.classList.remove('in');
if (d) { d.style.bottom = '8px'; d.classList.remove('in'); }
});
}
function play() {
var fast = seen;
zero(); void panel.offsetWidth;
panel.classList.remove('noanim');
var step = fast ? 85 : 135;
panel.querySelectorAll('.vcol').forEach(function (c, i) {
var h = +c.dataset.h, f = c.querySelector('.vfill'), v = c.querySelector('.vval'), d = c.querySelector('.vdelta');
timers.push(setTimeout(function () {
f.style.height = h + '%';
v.style.bottom = 'calc(' + h + '% + 6px)'; v.classList.add('in');
if (d) { d.style.bottom = 'calc(' + h + '% + 26px)'; d.classList.add('in'); }
}, 30 + i * step));
});
seen = true;
}
if (REDUCED) { play(); return; }
var bio = new IntersectionObserver(function (es) {
es.forEach(function (e) {
if (e.intersectionRatio >= .15) { if (!live) { live = true; play(); } }
else if (e.intersectionRatio <= 0) { live = false; zero(); }
});
}, { threshold: [0, .15] });
bio.observe(panel);
})();
/* ── Hero Right Panel: Self-Drawing Cumulative-Success SVG (#lchart) ── */
var redrawLchart = function () {};
(function () {
var svg = document.getElementById('lchart');
if (!svg) return;
var XS = [0, 10, 20, 30, 40, 50, 61, 75, 90, 100, 125];
var SER = [
{ k: 'sm', name: 'ACM', shortName: 'ACM', zhName: 'ACM', v: [0.0, 2.2, 18.0, 31.5, 40.4, 43.8, 49.4, 56.2, 58.4, 65.9, 65.9] },
{ k: 'lt', name: 'Vanilla Harness', shortName: 'Vanilla', zhName: 'Vanilla Harness', zhShort: '原生基线', v: [0.0, 3.4, 21.3, 33.7, 43.8, 49.4, 55.1, 60.7, 66.3, 74.2, 74.2] },
{ k: 'eh', name: 'Self-Context', shortName: 'Self-Context', zhName: 'Self-Context', v: [0.0, 6.7, 37.1, 55.1, 64.0, 69.7, 74.2, 78.7, 80.9, 82.0, 82.0] }
];
var Y0 = 0, Y1 = 92, TICKS = [20, 40, 60, 80];
var drawn = false;
function el(n, a) {
var e = document.createElementNS(NS, n);
for (var k in a) e.setAttribute(k, a[k]);
return e;
}
function render() {
var W = Math.max(280, Math.round(svg.getBoundingClientRect().width || svg.parentElement.clientWidth));
var narrow = W < 470;
var H = Math.round(Math.min(308, Math.max(224, W * (narrow ? 0.70 : 0.56))));
var L = 36, R = narrow ? 106 : 136, T = 20, B = 38;
var px = function (x) { return L + (x - XS[0]) / (XS[XS.length - 1] - XS[0]) * (W - L - R); };
var py = function (v) { return T + (Y1 - v) / (Y1 - Y0) * (H - T - B); };
svg.setAttribute('viewBox', '0 0 ' + W + ' ' + H);
svg.setAttribute('height', H);
svg.textContent = '';
TICKS.forEach(function (t) {
svg.appendChild(el('line', { class: 'gl', x1: L, x2: W - R, y1: py(t), y2: py(t) }));
var y = el('text', { class: 'ax', x: L - 6, y: py(t) + 4, 'text-anchor': 'end' });
y.textContent = t + '%'; svg.appendChild(y);
});
svg.appendChild(el('line', { class: 'ax-l', x1: L, x2: L, y1: T - 4, y2: H - B }));
svg.appendChild(el('line', { class: 'ax-l', x1: L, x2: W - R, y1: H - B, y2: H - B }));
[0, 25, 50, 75, 100, 125].forEach(function (x) {
var t = el('text', { class: 'ax', x: px(x), y: H - B + 16, 'text-anchor': 'middle' });
t.textContent = x; svg.appendChild(t);
});
var xt = el('text', { class: 'axt', x: (L + W - R) / 2, y: H - 4, 'text-anchor': 'middle' });
xt.textContent = curLang === 'zh' ? '交互轮次 (Turn)' : 'Agent Turn';
svg.appendChild(xt);
/* Dashed guide showing Turn 61 matching Vanilla Harness's final 74.2% */
svg.appendChild(el('line', { class: 'guide', x1: px(61), x2: px(100), y1: py(74.2), y2: py(74.2) }));
/* Collision-free right-hand label placement (sorted top-to-bottom: eh, lt, sm) */
var rawY = {}, placedY = {};
SER.forEach(function (s) { rawY[s.k] = py(s.v[s.v.length - 1]); });
var minGap = 34;
placedY.eh = Math.max(15, rawY.eh - 7);
placedY.lt = Math.max(placedY.eh + minGap, rawY.lt - 1);
placedY.sm = Math.max(placedY.lt + minGap, rawY.sm + 2);
if (placedY.sm + 15 > H - B - 2) {
placedY.sm = H - B - 17;
placedY.lt = Math.min(placedY.lt, placedY.sm - minGap);
placedY.eh = Math.min(placedY.eh, placedY.lt - minGap);
}
SER.forEach(function (s) {
var g = el('g', { class: 'ser ' + s.k });
var pts = XS.map(function (x, i) { return [px(x), py(s.v[i])]; });
var d = 'M ' + pts.map(function (p) { return p[0].toFixed(1) + ' ' + p[1].toFixed(1); }).join(' L ');
var len = 0;
for (var i = 1; i < pts.length; i++) len += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
var path = el('path', { class: 'ln', d: d });
path.style.setProperty('--len', Math.ceil(len));
g.appendChild(path);
[6, 9, 10].forEach(function (idx) {
g.appendChild(el('circle', { class: 'dot', cx: pts[idx][0], cy: pts[idx][1], r: s.k === 'eh' ? 3.2 : 2.3 }));
});
var last = pts[pts.length - 1];
var lx = last[0] + 10, ly = placedY[s.k];
if (Math.abs((ly + 3) - last[1]) > 2.5) {
var tick = el('path', {
class: 'dot',
d: 'M' + (last[0] + 4).toFixed(1) + ',' + last[1].toFixed(1) + ' L' + (lx - 3).toFixed(1) + ',' + (ly + 2).toFixed(1),
fill: 'none', stroke: 'currentColor', 'stroke-width': '1', 'stroke-opacity': '0.45'
});
tick.style.color = s.k === 'eh' ? 'var(--sc)' : (s.k === 'lt' ? 'var(--salmon-2)' : 'var(--ink-3)');
g.appendChild(tick);
}
var labelTxt = curLang === 'zh' ? (narrow ? (s.zhShort || s.zhName) : s.zhName) : (narrow ? s.shortName : s.name);
var nm = el('text', { class: 'endlab', x: lx, y: ly }); nm.textContent = labelTxt;
var vl = el('text', { class: 'endval', x: lx, y: ly + 15 }); vl.textContent = s.v[s.v.length - 1].toFixed(1) + '%';
g.appendChild(nm); g.appendChild(vl);
svg.appendChild(g);
});
if (drawn) {
svg.classList.add('in');
svg.querySelectorAll('.ln').forEach(function (p) { p.style.strokeDasharray = 'none'; p.style.strokeDashoffset = '0'; });
svg.querySelectorAll('.dot,.endlab,.endval').forEach(function (n) { n.style.opacity = '1'; });
}
}
redrawLchart = render;
render();
if (REDUCED) { drawn = true; render(); }
else {
var seen = false, live = false, anims = [];
function play() {
anims.forEach(function (x) { x.cancel(); }); anims = [];
var dur = seen ? 1800 : 3000, off = seen ? 180 : 340;
svg.classList.add('in');
Array.prototype.slice.call(svg.querySelectorAll('.ser')).forEach(function (g, i) {
var path = g.querySelector('.ln'), len = path.style.getPropertyValue('--len');
anims.push(path.animate(
[{ strokeDasharray: len, strokeDashoffset: len }, { strokeDasharray: len, strokeDashoffset: 0 }],
{ duration: dur, delay: i * off, easing: 'cubic-bezier(.38,.66,.3,1)', fill: 'both' }
));
var late = i * off + dur * 0.68;
Array.prototype.slice.call(g.querySelectorAll('.dot,.endlab,.endval')).forEach(function (node) {
anims.push(node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 420, delay: late, easing: 'ease', fill: 'both' }));
});
});
seen = true; drawn = true;
}
var lio = new IntersectionObserver(function (es) {
es.forEach(function (e) {
if (e.intersectionRatio >= .15 && !live) { live = true; requestAnimationFrame(play); }
else if (e.intersectionRatio <= 0) { live = false; svg.classList.remove('in'); }
});
}, { threshold: [0, .15] });
lio.observe(svg);
}
var rt;
window.addEventListener('resize', function () {
clearTimeout(rt);
rt = setTimeout(render, 140);
});
})();
/* ============================================================
02 · PLAYGROUND — LIVE SELF-CONTEXT XML SIMULATOR
============================================================ */
var refreshPlaygroundLang = function () {};
(function () {
var BASE_TURNS = [
{ n: 1, rawChars: 7420, call: 'get_document {"docid":"bio_884","lines":"1-120"}',
rawPreview: 'Full archival biography & 6 unrelated exhibition catalogs (7,420 chars)... "...Mira Vale (b. 1912, Larkspur)..."',
rawPreviewZh: '完整档案传记及 6 份无关展览目录(7,420 字符)……“…Mira Vale(1912 年生于 Larkspur)…”',
defaultFolded: true,
defaultNote: 'Biography confirms Mira Vale was born in Larkspur (1912); exhibition lists omitted.',
defaultNoteZh: '传记确认 Mira Vale 生于 Larkspur(1912 年);无关展览名录已折叠省略。' },
{ n: 2, rawChars: 3610, call: 'search {"query":"Larkspur valley river geography","k":10}',
rawPreview: '10 BM25 snippets (3,610 chars): 8 false-positive Larkspur CA hits; doc geo_419 mentions Larkspur Parish on River Alder.',
rawPreviewZh: '10 条 BM25 摘要(3,610 字符):8 条为加州同名干扰项;文档 geo_419 提及位于 River Alder 河畔的 Larkspur Parish。',
defaultFolded: false, defaultNote: '', defaultNoteZh: '' },
{ n: 3, rawChars: 1354, call: 'get_document {"docid":"geo_419","lines":"1-40"}',
rawPreview: 'Regional hydrography entry (1,354 chars): "Larkspur Parish sits along the upper bend of the River Alder."',
rawPreviewZh: '地方水文志词条(1,354 字符):“Larkspur Parish 位于 River Alder 上游河湾沿岸。”',
defaultFolded: false, defaultNote: '', defaultNoteZh: '' }
];
var PRESETS = {
add: {
doc: '<b>Graph Management · <code>op="add"</code>:</b> records a verified <code>finding</code> node under subgoal <code>s1</code> so it persists even after raw turns are folded.',
docZh: '<b>图管理 · <code>op="add"</code>:</b>在子目标 <code>s1</code> 下新增已验证的 <code>finding</code> 节点,即使原始轮次被折叠仍持久保留。',
xml: '<graph>\n <node op="add" id="f2" type="finding" parents="s1">\n Geo doc_419 confirms the River Alder runs through Larkspur.\n </node>\n</graph>'
},
fold: {
doc: '<b>History Management · <code>op="fold"</code>:</b> replaces Turn 2’s 3,610-char search dump in <code>F_t</code> with a concise summary note; <code>H_t</code> keeps every raw byte.',
docZh: '<b>历史管理 · <code>op="fold"</code>:</b>将第 2 轮 3,610 字符的检索结果在 <code>F_t</code> 中替换为一行摘要,原生历史 <code>H_t</code> 完整保留每个字节。',
xml: '<graph>\n <node op="fold" turns="2">\n Searched Larkspur rivers; 8 CA distractors ignored, geo_419 points to River Alder.\n </node>\n</graph>'
},
edit: {
doc: '<b>In-Place Revision · <code>op="edit"</code>:</b> promotes hypothesis <code>h1</code> to a verified <code>finding</code> in place instead of appending contradictory notes.',
docZh: '<b>原地修订 · <code>op="edit"</code>:</b>将候选假设 <code>h1</code> 原地升级为已验证 <code>finding</code>,避免只增不改造成的上下文前后矛盾。',
xml: '<graph>\n <node op="edit" id="h1" type="finding" parents="g">\n Verified: Mira Vale\'s birthplace (Larkspur) is traversed by the River Alder.\n </node>\n</graph>'
},
unfold: {
doc: '<b>Lossless Recovery · <code>op="unfold"</code>:</b> restores Turn 1 verbatim from native history <code>H_t</code> without re-executing <code>get_document</code>.',
docZh: '<b>无损恢复 · <code>op="unfold"</code>:</b>无需重新调用 <code>get_document</code>,直接从原生历史 <code>H_t</code> 逐字恢复第 1 轮原始内容。',
xml: '<graph>\n <node op="unfold" turns="1"/>\n</graph>'
},
remove: {
doc: '<b>Active Pruning · <code>op="remove"</code>:</b> retracts superseded plan/distractor node <code>d1</code> (0.88× remove-to-add ratio across paper runs).',
docZh: '<b>主动剪枝 · <code>op="remove"</code>:</b>移除已排除的干扰线索节点 <code>d1</code>(全量实验中删增比达 0.88×)。',
xml: '<graph>\n <node op="remove" id="d1"/>\n</graph>'
}
};
var state = null, curTab = 'add', customXml = {};
Object.keys(PRESETS).forEach(function (k) { customXml[k] = PRESETS[k].xml; });
function resetState() {
state = {
folded: { 1: curLang === 'zh' ? BASE_TURNS[0].defaultNoteZh : BASE_TURNS[0].defaultNote },
nodes: [
{ id: 'g', type: 'goal', parents: '', text: 'Find the river running through Mira Vale\'s birthplace.' },
{ id: 's1', type: 'subgoal', parents: 'g', text: 'Identify birthplace -> verify river in regional gazetteer.' },
{ id: 'f1', type: 'finding', parents: 's1', text: 'Mira Vale born in Larkspur (doc bio_884).' },
{ id: 'h1', type: 'hypothesis', parents: 's1', text: 'Candidate river: River Alder (pending geo_419 check).' },
{ id: 'd1', type: 'plan', parents: 's1', text: 'Distractor lead: Larkspur, California (Marin Creek).' }
],
applied: []
};
}
resetState();
var editor = document.getElementById('pgEditor'), docEl = document.getElementById('pgDoc');
var statusEl = document.getElementById('pgStatus'), verdictEl = document.getElementById('pgVerdict');
editor.value = customXml[curTab];
function renderPlayground(msg, isErr) {
var zh = curLang === 'zh';
var ftList = document.getElementById('pgFtList'), htList = document.getElementById('pgHtList');
var gList = document.getElementById('pgGraphList'), appEl = document.getElementById('pgApplied');
ftList.innerHTML = ''; htList.innerHTML = ''; gList.innerHTML = '';
var htTotal = BASE_TURNS.reduce(function (s, t) { return s + t.rawChars; }, 0);
var ftChars = 0;
BASE_TURNS.forEach(function (t) {
var isFolded = Object.prototype.hasOwnProperty.call(state.folded, t.n);
var defaultStub = zh ? (t.defaultNoteZh || '已由模型折叠(点击卡片或输出 unfold 恢复)。') : (t.defaultNote || 'Folded by model (click or emit unfold to restore).');
var note = state.folded[t.n] || defaultStub;
if (t.n === 1 && (note === t.defaultNote || note === t.defaultNoteZh)) {
note = zh ? t.defaultNoteZh : t.defaultNote;
}
var shownChars = isFolded ? 231 : t.rawChars;
ftChars += shownChars;
var prev = zh ? t.rawPreviewZh : t.rawPreview;
var fc = document.createElement('div');
fc.className = 'tcard' + (isFolded ? ' folded' : '');
fc.innerHTML = '<div class="thdr"><span>' + (zh ? ('第 ' + t.n + ' 轮' + (isFolded ? ' [已折叠]' : ' [原始]')) : ('Turn ' + t.n + (isFolded ? ' [folded]' : ' [raw]'))) +
'</span><span class="sz">' + shownChars.toLocaleString() + (zh ? ' 字符' : ' chars') + '</span></div>' +
'<div class="tbody">' + (isFolded ? ('[' + (zh ? ('第 ' + t.n + ' 轮已折叠') : ('Turn ' + t.n + ' folded')) + '] ' + note) : (t.call + ' -> ' + prev)) + '</div>';
fc.addEventListener('click', function () {
if (Object.prototype.hasOwnProperty.call(state.folded, t.n)) {
delete state.folded[t.n];
state.applied.push('unfold t' + t.n);
renderPlayground(zh ? ('已从 H_t 无损展开第 ' + t.n + ' 轮。') : ('Unfolded Turn ' + t.n + ' losslessly from H_t.'), false);
} else {
state.folded[t.n] = (zh ? t.defaultNoteZh : t.defaultNote) || (zh ? (t.call.split(' ')[0] + ' 输出摘要。') : ('Summary of ' + t.call.split(' ')[0] + ' output.'));
state.applied.push('fold t' + t.n);
renderPlayground(zh ? ('已折叠第 ' + t.n + ' 轮(' + t.rawChars.toLocaleString() + ' -> 231 字符)。') : ('Folded Turn ' + t.n + ' (' + t.rawChars.toLocaleString() + ' -> 231 chars).'), false);
}
});
ftList.appendChild(fc);
var hc = document.createElement('div');
hc.className = 'tcard raw-ro';
hc.innerHTML = '<div class="thdr"><span>' + (zh ? ('第 ' + t.n + ' 轮(调用配对完整)') : ('Turn ' + t.n + ' (paired IDs intact)')) +
'</span><span class="sz">' + t.rawChars.toLocaleString() + (zh ? ' 字符' : ' chars') + '</span></div>' +
'<div class="tbody">' + t.call + ' -> ' + prev + '</div>';
htList.appendChild(hc);
});
var gChars = 160;
state.nodes.forEach(function (nd) {
gChars += nd.text.length + 38;
var d = document.createElement('div');
d.className = 'gnode';
d.innerHTML = '<span class="gid">[' + nd.id + ']</span><span class="gtype">' + nd.type +
(nd.parents ? ' ← ' + nd.parents : '') + '</span>' + nd.text;
gList.appendChild(d);
});
var ctTotal = ftChars + gChars;
var pct = Math.round((ctTotal - htTotal) / htTotal * 1000) / 10;
document.getElementById('pgCtChars').textContent = ctTotal.toLocaleString();
document.getElementById('pgHtChars').textContent = htTotal.toLocaleString();
document.getElementById('pgDelta').textContent = (pct <= 0 ? pct : '+' + pct) + '%';
document.getElementById('pgRecoverable').textContent = zh ? '100% (12,384 字符)' : '100% (12,384 ch)';
document.getElementById('pgBadge').textContent = zh
? (state.nodes.length + ' 个活跃节点 · 已折叠 ' + Object.keys(state.folded).length + ' 轮')
: (state.nodes.length + ' active nodes · ' + Object.keys(state.folded).length + ' turn(s) folded');
docEl.innerHTML = zh ? PRESETS[curTab].docZh : PRESETS[curTab].doc;
if (!state.applied.length) {
appEl.innerHTML = '<span class="empty-stack">' + (zh ? '初始状态(第 1 轮已折叠,5 个工作图节点)' : 'initial episode state (t1 folded, 5 graph nodes)') + '</span>';
} else {
appEl.innerHTML = state.applied.slice(-6).map(function (x) {
return '<span class="stack-chip">' + x + '</span>';
}).join('');
}
if (msg) {
verdictEl.textContent = msg;
verdictEl.className = 'verdict ' + (isErr ? 'err' : 'ok');
statusEl.textContent = isErr ? (zh ? '解析提示' : 'parse warning') : (zh ? '已应用' : 'applied');
statusEl.className = 'status ' + (isErr ? 'err' : 'ok');
} else {
verdictEl.textContent = zh
? '第 1 轮在 F_t 中折叠为单行摘要;原始 7,420 字符传记在 H_t 中完整无损保存。'
: 'Turn 1 folded into a 1-line stub in F_t; raw 7,420-char biography stays intact in H_t.';
statusEl.textContent = zh ? '就绪' : 'ready';
}
}
refreshPlaygroundLang = function () { renderPlayground('', false); };
document.querySelectorAll('#pgTabs .tab').forEach(function (tb) {
tb.addEventListener('click', function () {
customXml[curTab] = editor.value;
curTab = tb.dataset.k;
document.querySelectorAll('#pgTabs .tab').forEach(function (x) { x.classList.toggle('active', x === tb); });
editor.value = customXml[curTab];
docEl.innerHTML = curLang === 'zh' ? PRESETS[curTab].docZh : PRESETS[curTab].doc;
});
});
document.getElementById('pgApply').addEventListener('click', function () {
var zh = curLang === 'zh';
var src = editor.value;
customXml[curTab] = src;
var re = /<node\b([^>]*?)(?:\/>|>([\s\S]*?)<\/node>)/gi, m, count = 0, summary = [];
while ((m = re.exec(src)) !== null) {
var attrs = {}, am, are = /(\w+)\s*=\s*"([^"]*)"/g;
while ((am = are.exec(m[1])) !== null) attrs[am[1].toLowerCase()] = am[2];
var op = (attrs.op || '').toLowerCase();
var body = (m[2] || '').replace(/\s+/g, ' ').trim();
if (!op) continue;
count++;
if (op === 'fold' || op === 'unfold') {
var nums = (attrs.turns || attrs.turn || attrs.id || '').match(/\d+/g) || [];
nums.forEach(function (ns) {
var k = parseInt(ns, 10);
if (k >= 1 && k <= 3) {
if (op === 'fold') state.folded[k] = body || (zh ? '已通过 <graph> 指令折叠。' : 'Folded via <graph> block.');
else delete state.folded[k];
state.applied.push(op + ' t' + k);
summary.push(op + ' t' + k);
}
});
} else if (op === 'remove' && attrs.id) {
state.nodes = state.nodes.filter(function (n) { return n.id !== attrs.id; });
state.applied.push('remove ' + attrs.id);
summary.push('remove [' + attrs.id + ']');
} else if ((op === 'add' || op === 'edit' || op === 'upsert') && attrs.id) {
var existing = state.nodes.find(function (n) { return n.id === attrs.id; });
if (existing) {
if (attrs.type) existing.type = attrs.type;
if (attrs.parents) existing.parents = attrs.parents;
if (body) existing.text = body;
} else {
state.nodes.push({ id: attrs.id, type: attrs.type || 'finding', parents: attrs.parents || 'g', text: body || '(empty node)' });
}
state.applied.push(op + ' ' + attrs.id);
summary.push(op + ' [' + attrs.id + ']');
}
}
if (!count) {
renderPlayground(zh ? '未解析到有效 <node op="..."/> 元素,请使用 op="add|edit|remove|fold|unfold"。' : 'No valid <node op="..."/> elements found. Use op="add|edit|remove|fold|unfold".', true);
} else {
renderPlayground(zh ? ('已成功应用 ' + count + ' 项操作:' + summary.join('、') + '。') : ('Applied ' + count + ' operation(s): ' + summary.join(', ') + '.'), false);
}
});
document.getElementById('pgReset').addEventListener('click', function () {
resetState();
statusEl.textContent = curLang === 'zh' ? '已重置' : 'reset';
statusEl.className = 'status';
renderPlayground(curLang === 'zh' ? '已重置为初始状态(第 1 轮已折叠,5 个工作图节点)。' : 'Episode reset to initial state (Turn 1 folded, 5 working-graph nodes).', false);
});
renderPlayground('', false);
})();
/* ============================================================
03 · TABBED ARCHITECTURE & CASE-STUDY VECTOR STAGE
============================================================ */
var syncStageLang = function () {};
(function () {
var mf = document.getElementById('methodFrame'), cf = document.getElementById('caseFrame');
var mSub = document.getElementById('methodSub'), extLink = document.getElementById('stageExtLink');
var SUB_EN = ['Turn & Parser', 'Unfold', 'Fold', 'Graph Ops', 'c_t Assembly'];
var SUB_ZH = ['单轮与解析', '按需展开', '整轮折叠', '图操作', '组装 c_t'];
var mBtns = [], curStage = 'method';
SUB_EN.forEach(function (label, k) {
var b = document.createElement('button');
b.type = 'button'; b.className = 'subbtn';
b.textContent = curLang === 'zh' ? SUB_ZH[k] : label;
b.setAttribute('aria-pressed', k === 0 ? 'true' : 'false');
b.addEventListener('click', function () {
mBtns.forEach(function (x, j) { x.setAttribute('aria-pressed', String(j === k)); });
if (mf && mf.contentWindow) try { mf.contentWindow.postMessage({ jumpGroup: k }, '*'); } catch (e) {}
});
mSub.appendChild(b); mBtns.push(b);
});
function pageHref(base) { return curLang === 'zh' ? (base + '?lang=zh') : base; }
function syncExtLinks() {
extLink.href = pageHref(curStage === 'method' ? 'method.html' : 'case-study.html');
['rlinkMethod', 'footMethod'].forEach(function (id) { var a = document.getElementById(id); if (a) a.href = pageHref('method.html'); });
['rlinkCase', 'footCase'].forEach(function (id) { var a = document.getElementById(id); if (a) a.href = pageHref('case-study.html'); });
}
var initQ = curLang === 'zh' ? '&lang=zh' : '';
mf.src = 'method.html?embed=1' + initQ;
cf.src = 'case-study.html?embed=1' + initQ;
syncExtLinks();
function syncFrameState(f) {
if (f && f.contentWindow) {
try {
f.contentWindow.postMessage({
theme: document.documentElement.getAttribute('data-theme'),
lang: curLang
}, '*');
} catch (e) {}
}
}
mf.addEventListener('load', function () { syncFrameState(mf); });
cf.addEventListener('load', function () { syncFrameState(cf); });
syncStageLang = function () {
mBtns.forEach(function (b, k) { b.textContent = curLang === 'zh' ? SUB_ZH[k] : SUB_EN[k]; });
syncExtLinks();
syncFrameState(mf);
syncFrameState(cf);
};
document.querySelectorAll('.stab').forEach(function (tab) {
tab.addEventListener('click', function () {
curStage = tab.dataset.stage;
document.querySelectorAll('.stab').forEach(function (t) { t.setAttribute('aria-selected', String(t === tab)); });
if (curStage === 'method') {
mf.classList.add('active'); cf.classList.remove('active');
mSub.style.display = 'flex';
syncExtLinks();
if (cf.contentWindow) try { cf.contentWindow.postMessage({ pause: true }, '*'); } catch (e) {}
} else {
cf.classList.add('active'); mf.classList.remove('active');
mSub.style.display = 'none';
syncExtLinks();
var caseIdx = curStage === 'case88' ? 0 : 1;
if (mf.contentWindow) try { mf.contentWindow.postMessage({ pause: true }, '*'); } catch (e) {}
setTimeout(function () {
if (cf.contentWindow) try { cf.contentWindow.postMessage({ selectCase: caseIdx, autoStart: !REDUCED, lang: curLang }, '*'); } catch (e) {}
}, 80);
}
});
});
window.addEventListener('message', function (e) {
if (!e.data) return;
if (typeof e.data.methodFollowed === 'number') {
mBtns.forEach(function (x, j) { x.setAttribute('aria-pressed', String(j === e.data.methodFollowed)); });
}
if (typeof e.data.methodHeight === 'number') {
mf.style.height = e.data.methodCompact ? Math.max(460, e.data.methodHeight + 4) + 'px' : '';
}
if (typeof e.data.caseHeight === 'number') {
cf.style.height = e.data.caseCompact ? Math.max(440, e.data.caseHeight + 4) + 'px' : '';
}
});
var startedMethod = false;
var fio = new IntersectionObserver(function (es) {
es.forEach(function (e) {
if (e.isIntersecting && !startedMethod && !REDUCED) {
startedMethod = true;
setTimeout(function () {
if (mf.contentWindow) try { mf.contentWindow.postMessage({ autoStart: true }, '*'); } catch (err) {}
}, 1200);
}
});
}, { threshold: 0.2 });
fio.observe(document.getElementById('stageShell'));
})();
/* ============================================================
04 · RESULTS — 9-METHOD EXPLORER & FULL 18-ROW TABLE 1
============================================================ */
var DATA = {
qwen38: {
label: 'Qwen3.8-27B',
rows: [
{ id: 'sla', name: 'SLA', bcp: [40.7, 0.6, 21.7], tb21: [21.7, 3.6, 90.2], qwenclaw: [24.0, 0.7, 58.7], macro: [28.8, 0, 56.9] },
{ id: 'mem1', name: 'Mem1', bcp: [36.6, 0.4, 13.5], tb21: [22.5, 1.1, 83.8], qwenclaw: [33.0, 1.2, 55.7], macro: [30.7, 0, 51.0] },
{ id: 'spell', name: 'Spell', bcp: [38.7, 0.4, 19.8], tb21: [49.1, 4.7, 12.6], qwenclaw: [46.8, 1.3, 8.8], macro: [44.9, 0, 13.7] },
{ id: 'self-compact', name: 'Self-Compact', bcp: [42.9, 0.7, 11.9], tb21: [56.9, 2.8, 52.4], qwenclaw: [61.9, 0.8, 20.4], macro: [53.9, 0, 28.2] },
{ id: 'clm', name: 'CLM', bcp: [43.6, 0.2, 18.9], tb21: [65.2, 1.1, 46.8], qwenclaw: [64.3, 3.6, 26.2], macro: [57.7, 0, 30.6] },
{ id: 'folding', name: 'Context-Folding', bcp: [55.3, 0.9, 22.2], tb21: [61.4, 0.6, 50.6], qwenclaw: [61.7, 0.2, 20.3], macro: [59.5, 0, 31.0] },
{ id: 'acm', name: 'ACM', bcp: [53.0, 1.2, 15.0], tb21: [65.9, 3.9, 48.1], qwenclaw: [69.7, 1.6, 23.4], macro: [62.9, 0, 28.8] },
{ id: 'vanilla', name: 'Vanilla Harness', role: 'van', bcp: [53.1, 1.8, 14.5], tb21: [74.2, 1.1, 49.3], qwenclaw: [65.0, 1.1, 17.1], macro: [64.1, 0, 27.0] },
{ id: 'ours', name: 'Self-Context', role: 'ours', bcp: [57.3, 0.3, 15.4], tb21: [82.0, 1.9, 33.6], qwenclaw: [70.2, 1.4, 12.8], macro: [69.8, 0, 20.6] }
]
},
qwen36: {
label: 'Qwen3.6-27B',
rows: [
{ id: 'mem1', name: 'Mem1', bcp: [28.7, 0.7, 24.0], tb21: [21.3, 1.9, 78.6], qwenclaw: [31.7, 1.5, 38.2], macro: [27.2, 0, 46.9] },
{ id: 'spell', name: 'Spell', bcp: [23.8, 1.4, 20.9], tb21: [30.0, 2.8, 13.5], qwenclaw: [33.1, 1.7, 8.2], macro: [29.0, 0, 14.2] },
{ id: 'sla', name: 'SLA', bcp: [34.5, 0.2, 22.8], tb21: [33.7, 1.1, 74.5], qwenclaw: [37.9, 3.2, 49.9], macro: [35.4, 0, 49.1] },
{ id: 'self-compact', name: 'Self-Compact', bcp: [33.3, 0.1, 15.0], tb21: [36.3, 3.6, 56.4], qwenclaw: [48.6, 1.8, 17.0], macro: [39.4, 0, 29.5] },
{ id: 'folding', name: 'Context-Folding', bcp: [49.8, 0.7, 25.2], tb21: [40.1, 1.7, 46.5], qwenclaw: [49.3, 0.3, 10.2], macro: [46.4, 0, 27.3] },
{ id: 'clm', name: 'CLM', bcp: [46.2, 1.4, 24.5], tb21: [42.7, 4.1, 54.3], qwenclaw: [50.2, 1.2, 30.0], macro: [46.4, 0, 36.3] },
{ id: 'acm', name: 'ACM', bcp: [43.1, 1.3, 16.4], tb21: [45.3, 0.6, 55.4], qwenclaw: [52.5, 2.2, 24.9], macro: [47.0, 0, 32.2] },
{ id: 'vanilla', name: 'Vanilla Harness', role: 'van', bcp: [41.6, 0.5, 15.9], tb21: [49.4, 1.9, 49.4], qwenclaw: [52.3, 0.9, 11.7], macro: [47.8, 0, 25.7] },
{ id: 'ours', name: 'Self-Context', role: 'ours', bcp: [47.3, 0.7, 17.5], tb21: [53.6, 3.6, 40.1], qwenclaw: [53.2, 0.6, 9.6], macro: [51.4, 0, 22.4] }
]
}
};
var BENCH_NAMES = {
en: {
macro: 'Macro Average (%)',
bcp: 'Search: BrowseComp-Plus Accuracy (%)',
tb21: 'Code: Terminal-Bench 2.1 Success (%)',
qwenclaw: 'Working: QwenClawBench v1.1 Mean Score (%)'
},
zh: {
macro: '三大基准宏平均 (%)',
bcp: '检索:BrowseComp-Plus 准确率 (%)',
tb21: '代码:Terminal-Bench 2.1 成功率 (%)',
qwenclaw: '办公:QwenClawBench v1.1 平均得分 (%)'
}
};
function populateTable1() {
var tbody = document.getElementById('fullTableBody');
tbody.innerHTML = '';
['qwen36', 'qwen38'].forEach(function (mKey) {
var m = DATA[mKey];
m.rows.forEach(function (r) {
var tr = document.createElement('tr');
if (r.role === 'ours') tr.className = 'ours-row';
var mName = r.role === 'ours' ? (curLang === 'zh' ? 'Self-Context(本文)' : 'Self-Context (Ours)') : r.name;
tr.innerHTML =
'<td>' + m.label + '</td>' +
'<td>' + mName + '</td>' +
'<td class="n">' + r.bcp[0].toFixed(1) + ' ± ' + r.bcp[1].toFixed(1) + '</td>' +
'<td class="n">' + r.bcp[2].toFixed(1) + '</td>' +
'<td class="n">' + r.tb21[0].toFixed(1) + ' ± ' + r.tb21[1].toFixed(1) + '</td>' +
'<td class="n">' + r.tb21[2].toFixed(1) + '</td>' +
'<td class="n">' + r.qwenclaw[0].toFixed(1) + ' ± ' + r.qwenclaw[1].toFixed(1) + '</td>' +
'<td class="n">' + r.qwenclaw[2].toFixed(1) + '</td>' +
'<td class="n">' + r.macro[0].toFixed(1) + '</td>' +
'<td class="n">' + r.macro[2].toFixed(1) + '</td>';
tbody.appendChild(tr);
});
});
}
populateTable1();
var curModel = 'qwen38', curBench = 'macro';
var bhead = document.getElementById('bhead'), plot = document.getElementById('plot'), arcSvg = document.getElementById('arcs');
var barEls = [];
function drawGainArc() {
while (arcSvg.firstChild) arcSvg.removeChild(arcSvg.firstChild);
var vanBar = barEls[7], oursBar = barEls[8];
if (!vanBar || !oursBar) return;
var pr = plot.getBoundingClientRect();
if (pr.width < 120) return;
arcSvg.setAttribute('viewBox', '0 0 ' + pr.width + ' ' + pr.height);
var r1 = vanBar.getBoundingClientRect(), r2 = oursBar.getBoundingClientRect();
var s1 = parseFloat(vanBar.dataset.score), s2 = parseFloat(oursBar.dataset.score);
var barTop1 = pr.height * (1 - Math.min(74, (s1 / BAR_SCALE) * 100) / 100);
var barTop2 = pr.height * (1 - Math.min(74, (s2 / BAR_SCALE) * 100) / 100);
var x1 = r1.left - pr.left + r1.width / 2, y1 = Math.max(32, barTop1 - 24);
var x2 = r2.left - pr.left + r2.width / 2, y2 = Math.max(32, barTop2 - 24);
var ctrlY = Math.max(14, Math.min(y1, y2) - 22);
var apexY = 0.25 * ((y1 + y2) / 2) + 0.75 * ctrlY;
var c1x = x1 + (x2 - x1) * 0.2, c2x = x2 - (x2 - x1) * 0.2;
var path = document.createElementNS(NS, 'path');
path.setAttribute('class', 'arcpath');
path.setAttribute('d', 'M' + x1.toFixed(1) + ',' + y1.toFixed(1) + ' C' + c1x.toFixed(1) + ',' + ctrlY.toFixed(1) + ' ' +
c2x.toFixed(1) + ',' + ctrlY.toFixed(1) + ' ' + x2.toFixed(1) + ',' + y2.toFixed(1));
arcSvg.appendChild(path);
var diff = (s2 - s1).toFixed(1);
var lbl = document.createElementNS(NS, 'text');
lbl.setAttribute('class', 'arclabel');
lbl.setAttribute('x', ((x1 + x2) / 2).toFixed(1));
lbl.setAttribute('y', Math.max(14, apexY - 6).toFixed(1));
lbl.textContent = (diff >= 0 ? '+' : '') + diff + ' pp';
arcSvg.appendChild(lbl);
}
function syncBarKicker() {
var m = DATA[curModel];
document.getElementById('barKicker').textContent =
(curLang === 'zh' ? '表 1 · ' : 'Table 1 · ') + m.label + ' · ' + BENCH_NAMES[curLang][curBench];
}
function buildBars() {
bhead.innerHTML = '';
Array.prototype.slice.call(plot.querySelectorAll('.bar')).forEach(function (n) { n.remove(); });
while (arcSvg.firstChild) arcSvg.removeChild(arcSvg.firstChild);
barEls = [];
var m = DATA[curModel];
syncBarKicker();
m.rows.forEach(function (r) {
var tup = r[curBench], score = tup[0], std = tup[1], turns = tup[2];
var hPct = Math.min(74, (score / BAR_SCALE) * 100);
var hd = document.createElement('div');
hd.className = 'bh' + (r.role ? ' ' + r.role : '');
hd.title = r.name + ' (' + turns.toFixed(1) + (curLang === 'zh' ? ' 平均轮次)' : ' mean turns)');
hd.innerHTML = '<span class="nm">' + r.name + '</span><span class="vr">' + turns.toFixed(1) + 't</span>';
bhead.appendChild(hd);
var bar = document.createElement('div');
bar.className = 'bar' + (r.role ? ' ' + r.role : '');
bar.style.setProperty('--h', hPct.toFixed(2) + '%');
bar.dataset.score = String(score);
bar.innerHTML = '<span class="bval">' + score.toFixed(1) + '</span><i class="bfill"></i>';
plot.insertBefore(bar, arcSvg);
barEls.push(bar);
if (window.SelfContextTooltip) {
SelfContextTooltip.bind(bar, function () {
var zh = curLang === 'zh';
var stdTxt = std > 0 ? ' ± ' + std.toFixed(1) + '%' : '%';
var nm = r.role === 'ours' ? (zh ? 'Self-Context(本文方法)' : 'Self-Context (Ours)') : r.name;
return '<span class="t">' + nm + ' · ' + m.label + '</span>' +
(zh ? '得分:' : 'Score: ') + '<span class="v">' + score.toFixed(1) + stdTxt + '</span> · ' +
(zh ? '平均轮次:' : 'Mean turns: ') + '<span class="v">' + turns.toFixed(1) + '</span>';
});
}
});
barEls.forEach(function (b, i) {
if (REDUCED) b.classList.add('on');
else setTimeout(function () { b.classList.add('on'); }, i * 45);
});
setTimeout(drawGainArc, REDUCED ? 0 : 480);
}
document.querySelectorAll('[data-model]').forEach(function (b) {
b.addEventListener('click', function () {
curModel = b.dataset.model;
document.querySelectorAll('[data-model]').forEach(function (x) { x.setAttribute('aria-pressed', String(x === b)); });
buildBars();
});
});
document.querySelectorAll('[data-bench]').forEach(function (b) {
b.addEventListener('click', function () {
curBench = b.dataset.bench;
document.querySelectorAll('[data-bench]').forEach(function (x) { x.setAttribute('aria-pressed', String(x === b)); });
buildBars();
});
});
window.addEventListener('resize', drawGainArc);
buildBars();
/* Table 1 Expand/Collapse */
var tb = document.getElementById('tableBtn'), tables = document.getElementById('tables');
function syncTableBtn() {
var isOpen = !tables.hidden;
tb.textContent = curLang === 'zh'
? (isOpen ? '收起完整论文表 1 ↑' : '展开完整 18 行论文表 1 ↓')
: (isOpen ? 'Hide complete paper Table 1 ↑' : 'View complete 18-row paper Table 1 ↓');
}
tb.addEventListener('click', function () {
var open = tables.hidden;
tables.hidden = !open;
tb.setAttribute('aria-expanded', String(open));
syncTableBtn();
});
/* Bind [data-tip] & .org tooltips (language-aware) */
if (window.SelfContextTooltip) {
document.querySelectorAll('[data-tip]').forEach(function (el) {
SelfContextTooltip.bind(el, function () {
var raw = (curLang === 'zh' && el.getAttribute('data-tip-zh')) ? el.getAttribute('data-tip-zh') : el.getAttribute('data-tip');
var parts = raw.split('|');
return '<span class="t">' + parts[0] + '</span>' + (parts[1] || '');
});
});
document.querySelectorAll('.org').forEach(function (a) {
SelfContextTooltip.bind(a, function () {
return '<span class="t">' + a.dataset.org + '</span>' + (a.dataset.sub || '');
});
});
}
/* One-Click BibTeX Copy */
var cCopy = document.getElementById('citationCopy'), cText = document.getElementById('citationText');
function syncCopyBtn() {
cCopy.textContent = curLang === 'zh' ? '复制 BibTeX' : 'Copy BibTeX';
}
cCopy.addEventListener('click', async function () {
var txt = cText.textContent, ok = false;
try {
if (navigator.clipboard && navigator.clipboard.writeText) { await navigator.clipboard.writeText(txt); ok = true; }
} catch (e) {}
if (!ok) {
var ta = document.createElement('textarea');
ta.value = txt; ta.style.cssText = 'position:fixed;opacity:0';
document.body.appendChild(ta); ta.select();
try { ok = document.execCommand('copy'); } catch (e) {}
ta.remove();
}
if (ok) {
cCopy.textContent = curLang === 'zh' ? '已复制 ✓' : 'Copied ✓';
setTimeout(syncCopyBtn, 1800);
}
});
/* ── Master Language Application & Toggle ── */
var langBtn = document.getElementById('langBtn');
function applyLang(next, pushUrl) {
curLang = next === 'zh' ? 'zh' : 'en';
document.documentElement.setAttribute('data-lang', curLang);
document.documentElement.setAttribute('lang', curLang === 'zh' ? 'zh-CN' : 'en');
localStorage.setItem('lang', curLang);
document.title = curLang === 'zh'
? 'Self-Context:面向长程智能体的图结构上下文自管理框架'
: 'Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents';
langBtn.textContent = curLang === 'zh' ? 'EN' : '中文';
langBtn.setAttribute('aria-label', curLang === 'zh' ? 'Switch to English' : '切换为中文');
i18nNodes.forEach(function (el) {
var k = el.getAttribute('data-i18n');
el.innerHTML = (curLang === 'zh' && ZH[k]) ? ZH[k] : el._en;
});
syncThemeBtn();
syncTableBtn();
syncCopyBtn();
syncBarKicker();
populateTable1();
redrawLchart();
refreshPlaygroundLang();
syncStageLang();
syncHud();
var sv = document.getElementById('showcaseVideo'), sl = document.getElementById('showcaseLink');
var targetVid = curLang === 'zh' ? 'static/media/showcase_zh.mp4' : 'static/media/showcase_en.mp4';
if (sv && sv.getAttribute('src') !== targetVid) {
sv.setAttribute('src', targetVid);
sv.load();
if (!REDUCED) { var vp = sv.play(); if (vp && vp.catch) vp.catch(function () {}); }
}
if (sl) sl.href = targetVid;
if (pushUrl && window.history && window.history.replaceState) {
try {
var u = new URL(location.href);
if (curLang === 'zh') u.searchParams.set('lang', 'zh');
else u.searchParams.delete('lang');
window.history.replaceState(null, '', u.pathname + u.search + u.hash);
} catch (e) {}
}
}
langBtn.addEventListener('click', function () {
applyLang(curLang === 'zh' ? 'en' : 'zh', true);
});
applyLang(curLang, false);
})();
</script>
</body>
</html>
<html lang="en" data-theme="light" data-lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents</title>
<meta name="description" content="Self-Context wraps a frozen LLM and its native agent harness in a drop-in context gateway: an editable working graph plus reversible whole-turn history folding (c_t = F_t ⊕ G_t).">
<link rel="canonical" href="https://self-context.github.io/">
<link rel="icon" type="image/svg+xml" href="static/images/favicon.svg">
<meta property="og:site_name" content="Self-Context">
<meta property="og:type" content="website">
<meta property="og:title" content="Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents">
<meta property="og:description" content="Harnesses stuff the prompt. Self-Context lets the model curate it: +5.7 pp macro-average gain and 23.7% fewer turns on Qwen3.8-27B.">
<meta property="og:url" content="https://self-context.github.io/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents">
<meta name="twitter:description" content="Drop-in inference-time working graph and reversible whole-turn history folding for long-horizon LLM agents.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@300..800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Literata:ital,opsz,wght@0,7..72,400..600;1,7..72,400..600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Google+Sans+Code:ital,wght@0,300..700;1,300..700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="static/css/main.css">
<script src="static/js/tooltips.js"></script>
<script>
(function () {
var t = localStorage.getItem('theme') ||
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', t);
var qp = null;
try { qp = new URLSearchParams(location.search).get('lang'); } catch (e) {}
var lg = (qp === 'zh' || qp === 'en') ? qp : (localStorage.getItem('lang') || 'en');
document.documentElement.setAttribute('data-lang', lg);
document.documentElement.setAttribute('lang', lg === 'zh' ? 'zh-CN' : 'en');
})();
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ScholarlyArticle",
"name": "Self-Context",
"headline": "Self-Context: Graph-Based Context Self-Management for Long-Horizon Agents",
"url": "https://self-context.github.io/",
"sameAs": "https://arxiv.org/abs/2612.01681",
"codeRepository": "https://github.com/XMUDeepLIT/Self-Context",
"author": [
{"@type":"Person","name":"Ziheng Wang"},
{"@type":"Person","name":"Chengyi Yang"},
{"@type":"Person","name":"Renxu Bao"},
{"@type":"Person","name":"Zhishang Xiang"},
{"@type":"Person","name":"Chengsong Huang"},
{"@type":"Person","name":"Wenhao Li"},
{"@type":"Person","name":"Junnan Zhu"},
{"@type":"Person","name":"Delai Qiu"},
{"@type":"Person","name":"Yining Wang"},
{"@type":"Person","name":"Shengping Liu"},
{"@type":"Person","name":"Jinsong Su"}
]
}
</script>
</head>
<body>
<!-- ============ HUD NAV ============ -->
<header class="hud" id="hud">
<div class="hud-in">
<a class="wordmark" href="#top">
<img class="mark" src="static/images/favicon.svg" alt="" width="22" height="22">
Self-Context
</a>
<nav class="hud-nav" aria-label="Primary navigation">
<a href="#idea" class="hide-s" data-i18n="nav_idea">Idea</a>
<a href="#play" data-i18n="nav_play">Playground</a>
<a href="#architecture" class="hide-s" data-i18n="nav_arch">Architecture</a>
<a href="#results" data-i18n="nav_res">Results</a>
<a href="#discussion" class="hide-m" data-i18n="nav_disc">Discussion</a>
<a href="#gateway" class="hide-m" data-i18n="nav_gw">Gateway</a>
<a href="#cite" class="hide-s" data-i18n="nav_cite">Cite</a>
<a href="https://arxiv.org/abs/2612.01681" class="navbtn" target="_blank" rel="noopener" data-i18n="nav_paper">Paper ↗</a>
<a href="https://github.com/XMUDeepLIT/Self-Context" class="navbtn hide-s" target="_blank" rel="noopener" data-i18n="nav_code">Code ↗</a>
<button class="tbtn lang-btn" id="langBtn" type="button" aria-label="Switch language">中文</button>
<button class="tbtn" id="themeBtn" type="button" aria-label="Toggle color theme">Dark</button>
</nav>
</div>
<nav class="mob-nav" aria-label="Mobile section links">
<a href="#idea" data-i18n="mnav_idea">01 Idea</a>
<a href="#play" data-i18n="mnav_play">02 Playground</a>
<a href="#architecture" data-i18n="mnav_arch">03 Architecture</a>
<a href="#results" data-i18n="mnav_res">04 Results</a>
<a href="#discussion" data-i18n="mnav_disc">05 Discussion</a>
<a href="#gateway" data-i18n="mnav_gw">06 Gateway</a>
<a href="#cite" data-i18n="mnav_cite">07 Cite</a>
<a href="https://github.com/XMUDeepLIT/Self-Context" target="_blank" rel="noopener" data-i18n="nav_code">Code ↗</a>
</nav>
</header>