skills/skillxiv-v0.0.2-claude-opus-4.6/agent-long-context-benchmark/SKILL.md
Build controllable benchmarks for evaluating long-context agents using environment rollouts. Generate diverse multi-step agent tasks that require maintaining context across extended interaction sequences, enabling evaluation of agent reasoning quality in scenarios with long history requirements.
npx skillsauth add ADu2021/skillXiv agent-long-context-benchmarkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Existing agent benchmarks typically use short, isolated tasks that don't reflect real-world requirements where agents must maintain context and reason over long interaction histories. Long-context agents need benchmarks that can systematically vary task complexity, history length, and environmental conditions to properly evaluate their capabilities.
Create AgentLongBench: a controllable benchmark framework that generates synthetic long-context agent tasks through environment rollouts. This approach allows you to:
Create a controllable environment that generates long-context agent interactions.
class LongContextEnvironment:
"""Simulation environment for generating long interaction sequences"""
def __init__(self, complexity_level=1, max_steps=50):
self.complexity = complexity_level # 1-5 scale
self.max_steps = max_steps
self.state = self.initialize_state()
self.step_count = 0
self.history = []
def initialize_state(self):
"""Set up initial task and environment state"""
return {
"goal": self.generate_goal(self.complexity),
"environment_objects": self.generate_objects(self.complexity),
"available_actions": self.available_actions(),
"current_progress": 0.0
}
def step(self, agent_action):
"""
Execute one agent action and return observation + reward
Returns: (observation, reward, done, info)
"""
self.step_count += 1
# Validate and execute action
is_valid = self.validate_action(agent_action)
if not is_valid:
observation = self.get_observation()
return observation, -1.0, False, {"error": "invalid_action"}
# Apply action to environment
result = self.apply_action(agent_action)
observation = self.get_observation()
# Track in history
self.history.append({
"step": self.step_count,
"action": agent_action,
"result": result,
"state_snapshot": self.state.copy()
})
# Compute reward
progress_delta = self.get_progress() - self.state["current_progress"]
reward = progress_delta * 10 # Scale reward signal
self.state["current_progress"] += progress_delta
done = (self.step_count >= self.max_steps) or self.goal_reached()
return observation, reward, done, {"history_length": len(self.history)}
def get_observation(self):
"""Return current observation including history summary"""
return {
"step": self.step_count,
"goal": self.state["goal"],
"visible_objects": self.get_visible_objects(),
"recent_actions": self.history[-5:], # Last 5 actions
"progress_toward_goal": self.state["current_progress"],
"available_actions": self.state["available_actions"]
}
Create diverse tasks at varying complexity levels.
def generate_goal(complexity_level):
"""Generate task goal based on complexity"""
if complexity_level == 1:
return "Find and retrieve item X"
elif complexity_level == 2:
return "Complete sequence: find X, transform with Y, store in Z"
elif complexity_level == 3:
return "Multi-constraint planning: achieve A while maintaining B, avoid C"
elif complexity_level == 4:
return "Complex reasoning: infer hidden rules from observations, then achieve goal"
else:
return "Open-ended exploration and adaptation to changing goals"
def generate_environment_rollout(num_steps, complexity):
"""Generate a full trajectory of environment interactions"""
env = LongContextEnvironment(complexity_level=complexity, max_steps=num_steps)
trajectory = []
observation = env.get_observation()
done = False
while not done and env.step_count < num_steps:
# Simulate a sequence of reasonable actions
action = select_trajectory_action(observation, env.state["goal"])
observation, reward, done, info = env.step(action)
trajectory.append({
"observation": observation,
"action": action,
"reward": reward,
"done": done
})
return {
"trajectory": trajectory,
"final_success": env.goal_reached(),
"steps_taken": env.step_count,
"context_length": len(env.history)
}
Generate a collection of tasks at different complexity and length levels.
class AgentLongBench:
"""Full benchmark for long-context agent evaluation"""
def __init__(self, num_tasks_per_level=10, max_context_length=1000):
self.num_tasks = num_tasks_per_level
self.max_context_length = max_context_length
self.tasks = self.generate_benchmark()
def generate_benchmark(self):
"""Create diverse tasks across complexity and context length dimensions"""
benchmark = {
"easy": [],
"medium": [],
"hard": [],
"very_hard": [],
"expert": []
}
# Easy: short context, simple goals
for i in range(self.num_tasks):
rollout = generate_environment_rollout(num_steps=10, complexity=1)
benchmark["easy"].append(rollout)
# Medium: longer context, multi-step goals
for i in range(self.num_tasks):
rollout = generate_environment_rollout(num_steps=30, complexity=2)
benchmark["medium"].append(rollout)
# Hard: long context, complex reasoning
for i in range(self.num_tasks):
rollout = generate_environment_rollout(num_steps=50, complexity=3)
benchmark["hard"].append(rollout)
# Very Hard: very long context with constraints
for i in range(self.num_tasks):
rollout = generate_environment_rollout(num_steps=100, complexity=4)
benchmark["very_hard"].append(rollout)
# Expert: longest context, open-ended adaptation
for i in range(self.num_tasks):
rollout = generate_environment_rollout(
num_steps=min(150, self.max_context_length),
complexity=5
)
benchmark["expert"].append(rollout)
return benchmark
def evaluate_agent(self, agent, difficulty="easy"):
"""
Run agent on benchmark tasks and compute metrics
"""
tasks = self.tasks[difficulty]
results = {
"success_rate": 0.0,
"avg_steps": 0.0,
"avg_history_length": 0.0,
"context_efficiency": 0.0
}
successes = 0
total_steps = 0
total_history_length = 0
for task in tasks:
# Reset agent for task
agent.reset()
# Run agent through task
trajectory = task["trajectory"]
task_success = False
for step_data in trajectory:
observation = step_data["observation"]
action = agent.act(observation)
# (evaluate action against expected behavior)
if action == step_data["action"]:
task_success = True
if task_success:
successes += 1
total_steps += task["steps_taken"]
total_history_length += task["context_length"]
results["success_rate"] = successes / len(tasks)
results["avg_steps"] = total_steps / len(tasks)
results["avg_history_length"] = total_history_length / len(tasks)
results["context_efficiency"] = results["success_rate"] / (
results["avg_history_length"] / self.max_context_length
)
return results
Use the benchmark for iterative agent improvement.
def train_agent_with_benchmark(agent, benchmark, num_epochs=10):
"""
Train agent using AgentLongBench with curriculum learning
Start with easy tasks, progress to harder ones
"""
difficulties = ["easy", "medium", "hard", "very_hard", "expert"]
for epoch in range(num_epochs):
for difficulty in difficulties:
# Evaluate on current difficulty
metrics = benchmark.evaluate_agent(agent, difficulty)
# Stop if success rate drops too low
if metrics["success_rate"] < 0.3:
continue
# Train agent on this difficulty level
agent.train_on_tasks(benchmark.tasks[difficulty], epochs=1)
print(f"Epoch {epoch}, Difficulty {difficulty}: "
f"Success={metrics['success_rate']:.2f}, "
f"ContextEff={metrics['context_efficiency']:.2f}")
testing
Uses flow maps as look-ahead operators to enable principled reward-guided diffusion by predicting trajectory endpoints at any denoising step. Deploy when applying rewards or preferences to diffusion trajectories with meaningful gradients throughout generation.
testing
Train language models where each expert learns independently on closed datasets, enabling flexible inference with selective data inclusion or exclusion. 41% performance improvement while allowing users to opt out of specific data sources without retraining.
data-ai
Understand how token generation flexibility in diffusion LMs paradoxically constrains reasoning, as models exploit ordering flexibility to avoid uncertain tokens, and apply simplified approaches that preserve parallel decoding benefits. Use when optimizing diffusion-based language models for reasoning tasks.
devops
Enable LLM agents to improve continuously during deployment by constructing structured experience libraries through self-reflection on successes and failures—achieving 23% improvement on reasoning without gradient-based parameter updates or external training.