SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2609.14872 · September 2026

AgentKV: Phase-Aware KV Eviction for Agentic LLMs

Hao Chen, Yiren Zhao, Bowen Yang, Jeffrey Wong, Hao Mark Chen, Jeffrey T. H. Wong, Taowen Liu, Can Xiao, Taowen Tony Liu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 4 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2609.14872.json · badge: /api/ran/2609.14872.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
LiuTaowen-Tony/agentkv canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
estimate_chat_tokens Ran
ran, honoured the contract we drafted
LiuTaowen-Tony/agentkv/experiment/runners/simple_profile.py
code served (permissive licence) · get_code("79be7194174c3157")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

class StandInTokenizer:
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        # Simulate tokenization by returning a list of token ids
        # The function only cares about the length of the returned list
        token_count = 0
        for message in messages:
            # Count tokens based on message content length as a simple heuristic
            token_count += len(message.get("content", "").split()) + 2
        if add_generation_prompt:
            token_count += 3
        return list(range(token_count))

messages = [
    {"role": "user", "content": "Hello how are you"},
    {"role": "assistant", "content": "I am doing well"}
]

tokenizer = StandInTokenizer()

ARGS = {
    "tokenizer": tokenizer,
    "messages": messages
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
model_spec Ran
ran; our contract draft was wrong, not the code
LiuTaowen-Tony/agentkv/experiment/runners/common.py
code served (permissive licence) · get_code("1f4c3c9829a39a77")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ModelSpec. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import dataclasses
from dataclasses import dataclass
from pathlib import Path

@dataclass(frozen=True)
class ModelSpec:
    name: str
    path: str
    bfcl_model: str
    tau2_agent_llm: str

MODELS = {'qwen3-8b': ModelSpec(name='qwen3-8b', path='Qwen/Qwen3-8B', bfcl_model='qwen3-8b-minisglang-prompt', tau2_agent_llm='openai/qwen3-8b-minisglang'), 'qwen3-32b': ModelSpec(name='qwen3-32b', path='Qwen/Qwen3-32B', bfcl_model='qwen3-32b-minisglang-prompt', tau2_agent_llm='openai/qwen3-32b-minisglang')}

def resolve_model_path(hf_repo: str) -> str:
    """Return a local snapshot dir for `hf_repo` if AGENTKV_MODEL_DIR points at an HF cache
    that already has it; otherwise return the HF repo id unchanged (engine will download)."""
    base = os.environ.get('AGENTKV_MODEL_DIR')
    if base:
        snaps = Path(base) / 'hub' / ('models--' + hf_repo.replace('/', '--')) / 'snapshots'
        if snaps.is_dir():
            revs = sorted((p for p in snaps.iterdir() if p.is_dir()))
            if revs:
                return str(revs[-1])
    return hf_repo

def model_spec(name: str) -> ModelSpec:
    try:
        spec = MODELS[name]
    except KeyError:
        raise RuntimeError(f'unknown model name: {name}. expected one of {sorted(MODELS)}')
    return dataclasses.replace(spec, path=resolve_model_path(spec.path))

# Setup code
os.environ.pop('AGENTKV_MODEL_DIR', None)

ARGS = {
    'name': 'qwen3-8b'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ModelSpec — a ModelSpec output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModelSpec output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
resolve_model_path Ran
ran; our contract draft was wrong, not the code
LiuTaowen-Tony/agentkv/experiment/runners/common.py
code served (permissive licence) · get_code("b109979c9005d347")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
from pathlib import Path
import tempfile
import shutil

# Create a temporary directory structure that mimics HF cache layout
temp_dir = tempfile.mkdtemp()
base_dir = Path(temp_dir)

# Create the HF cache structure
hub_dir = base_dir / 'hub'
hub_dir.mkdir(parents=True, exist_ok=True)

# Create a models directory for a test repo
repo_name = 'meta-llama/Llama-2-7b'
model_dir_name = 'models--' + repo_name.replace('/', '--')
model_path = hub_dir / model_dir_name
model_path.mkdir(parents=True, exist_ok=True)

# Create snapshots directory with a revision
snapshots_dir = model_path / 'snapshots'
snapshots_dir.mkdir(parents=True, exist_ok=True)

# Create a revision directory (using a hash-like string)
revision_dir = snapshots_dir / 'abc123def456ghi789jkl012mno345pqr'
revision_dir.mkdir(parents=True, exist_ok=True)

# Set the environment variable to point to our temp directory
os.environ['AGENTKV_MODEL_DIR'] = str(base_dir)

# Test cases for different scenarios
ARGS = {
    'hf_repo': 'meta-llama/Llama-2-7b'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
response_text Ran
ran; our contract draft was wrong, not the code
LiuTaowen-Tony/agentkv/experiment/runners/simple_profile.py
code served (permissive licence) · get_code("5a32b8b4dd3c051d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

class Message:
    def __init__(self, content, model_extra=None):
        self.content = content
        self.model_extra = model_extra

# Test case 1: message with raw_content in model_extra
message_with_raw = Message(
    content='default content',
    model_extra={'raw_content': 'raw response text'}
)

# Test case 2: message with just content
message_with_content = Message(
    content='just content',
    model_extra=None
)

# Test case 3: message with empty model_extra
message_empty_extra = Message(
    content='content here',
    model_extra={}
)

# Use the first test case for ARGS
ARGS = {
    'message': message_with_raw
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
slugify_name Ran
ran; our contract draft was wrong, not the code
LiuTaowen-Tony/agentkv/experiment/runners/common.py
code served (permissive licence) · get_code("59bcf4a7af53a84f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

ARGS = {
    'value': 'Hello-World_Test 123!'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
task_summary Ran
ran; our contract draft was wrong, not the code
LiuTaowen-Tony/agentkv/experiment/runners/tau2.py
code served (permissive licence) · get_code("d2343ebd5ef65c41")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from pathlib import Path
import tempfile
import shutil

# Create a temporary directory structure to simulate ROOT / 'tau2-bench' / ...
temp_dir = tempfile.mkdtemp()
ROOT = Path(temp_dir)

# Create the necessary directory structure
domains_base = ROOT / 'tau2-bench' / 'data' / 'tau2' / 'domains'
domains_base.mkdir(parents=True, exist_ok=True)

# Create two test domains
test_domains = ['domain1', 'domain2']

for domain in test_domains:
    domain_path = domains_base / domain
    domain_path.mkdir(exist_ok=True)
    
    # Create split_tasks.json
    split_tasks = {
        'train': [0, 1, 2, 0, 1],
        'test': [3, 4],
        'val': [5, 6, 7]
    }
    split_path = domain_path / 'split_tasks.json'
    split_path.write_text(json.dumps(split_tasks))
    
    # Create tasks.json with some task entries
    tasks = {
        str(i): {'name': f'task_{i}', 'description': f'Task {i}'}
        for i in range(10)
    }
    task_path = domain_path / 'tasks.json'
    task_path.write_text(json.dumps(tasks))

# Set ROOT as a global so the function can access it
import builtins
builtins.ROOT = ROOT

ARGS = {
    'split': 'train',
    'domains': ['domain1', 'domain2']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
main Not yet run
unverified (harvested, no recorded run)
LiuTaowen-Tony/agentkv/experiment/runners/bfcl.py
code served (permissive licence) · get_code("8c62fac91d309ed8")
How it ran

no invocation recorded.

main Not yet run
unverified (harvested, no recorded run)
LiuTaowen-Tony/agentkv/experiment/runners/tau2.py
code served (permissive licence) · get_code("9e4112999274379f")
How it ran

no invocation recorded.

run_from_args Not yet run
unverified (harvested, no recorded run)
LiuTaowen-Tony/agentkv/experiment/runners/bfcl.py
code served (permissive licence) · get_code("3589a947e6e2b3c7")
How it ran

no invocation recorded.

run_from_args Not yet run
unverified (harvested, no recorded run)
LiuTaowen-Tony/agentkv/experiment/runners/tau2.py
code served (permissive licence) · get_code("6356caa7ab3fd52d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Agentic serving can consume orders of magnitude more tokens than chatbot workloads, stressing both KV-cache capacity and decode-time bandwidth. Most KV-eviction methods score cached keys against representative queries drawn from the most recent tokens, assuming future attention resembles recent attention. We show that agentic generation violates this assumption: future queries form a mixture over think, act, tool, and others phases, and principal-angle analysis shows these components occupy measurably different query subspaces, so recency representatives systematically undervalue keys that upcoming phases will need. We propose AGENTKV, which maintains a small query buffer per phase and scores cached keys against their union. We further implement AGENTKV in a persistent multi-turn serving path that carries compressed KV state across turns and compacts retained KV pages online. Across two models, six task domains, and three KV budgets each, AGENTKV improves task score by 5.5 points on average over R-KV and 5.3 over Tri-attention. Relative to upstream full-KV SGLang, AGENTKV improves output-token throughput by up to 1.80x. Code: https://github.com/LiuTaowen-Tony/agentkv.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2609.14872")
get_code_for_paper("2609.14872")
have("2609.14872")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2609.14872.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2609.14872.svg)](https://syntology.ai/paper/2609.14872)

Connect an agent — have() is free.