Skip to main content 首页 创作者 adu2021 skillxiv redsearcher-long-horizon-agents
redsearcher-long-horizon-agents Train language models for multi-step information-seeking using dual-constrained task synthesis and cost-efficient staged learning. Generate complex queries by controlling topological complexity and information dispersion, then train atomic reasoning skills before introducing environment interaction. Achieve state-of-the-art on long-horizon search benchmarks with 30B parameter models.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ADu2021/skillXiv --skill redsearcher-long-horizon-agents命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... name redsearcher-long-horizon-agents title REDSearcher: Scalable Framework for Long-Horizon Search Agents version 0.0.2 engine skillxiv-v0.0.2-claude-opus-4.6 license MIT url https://arxiv.org/abs/2602.14234 keywords ["Information Seeking","Long-Horizon Planning","Reinforcement Learning","Search Agents","Tool Use"] description Train language models for multi-step information-seeking using dual-constrained task synthesis and cost-efficient staged learning. Generate complex queries by controlling topological complexity and information dispersion, then train atomic reasoning skills before introducing environment interaction. Achieve state-of-the-art on long-horizon search benchmarks with 30B parameter models.
REDSearcher: Scalable Framework for Long-Horizon Search Agents
Problem Context
Language models for information-seeking (web search, retrieval) face extreme sparsity: high-quality search trajectories are rare, multi-step reasoning is expensive, and real-world API costs prohibit extensive exploration. REDSearcher addresses this by (1) generating diverse, challenging synthetic tasks, (2) training fundamental skills in controlled environments, (3) scaling to real interaction only after skills solidify.
Core Concept
REDSearcher operates in three phases: (1) dual-constrained task synthesis creating complex search problems, (2) atomic skill learning (grounding, planning) in simulation, (3) hierarchical trajectory training with environment interaction. This staged approach reduces expensive real-world costs while maintaining quality.
Architecture Overview
Dual constraints : Control task complexity (graph treewidth) and information dispersion
Tool-augmented synthesis : Convert facts into tool-resolvable constraints (API calls)
Atomic skills : Intent grounding, hierarchical planning, fact composition
Simulation environment : Local search environment with millions of documents
Staged training : Skills → hierarchical planning → environment interaction
Long-horizon support : 30+ step trajectories with explicit reasoning
Implementation
Step 1: Dual-constrained task synthesis
import networkx as nx
from typing import Dict , List , Tuple , Set
import random
class DualConstraintedTaskSynthesis :
"""Generate search tasks with controlled complexity."""
def __init__ (
self,
document_corpus: List [str ],
entity_graph: nx.DiGraph,
max_treewidth: int = 5
):
self .corpus = document_corpus
.entity_graph = entity_graph
.max_treewidth = max_treewidth
( ) -> :
(subgraph.nodes) == :
degrees = [subgraph.degree(n) n subgraph.nodes]
(degrees) degrees
( ) -> :
num_entities = (target_treewidth + , ( .entity_graph.nodes))
selected_entities = random.sample( ( .entity_graph.nodes), num_entities)
subgraph = .entity_graph.subgraph(selected_entities)
actual_treewidth = .compute_treewidth(subgraph)
actual_treewidth > .max_treewidth:
high_degree_nodes = [n n subgraph.nodes subgraph.degree(n) > ]
selected_entities = [e e selected_entities e high_degree_nodes]
gold_facts = []
source, target subgraph.edges:
relation = .entity_graph.edges[source, target].get( , )
gold_facts.append( )
facts_per_doc = ( , (gold_facts) // ( , ( ( .corpus) * information_dispersion)))
document_assignments = {}
doc_idx ( ( .corpus)):
assigned_facts = gold_facts[
doc_idx * facts_per_doc:(doc_idx + ) * facts_per_doc
]
assigned_facts:
document_assignments[doc_idx] = assigned_facts
question = ._generate_question(selected_entities, gold_facts)
{
: question,
: gold_facts,
: document_assignments,
: selected_entities,
: actual_treewidth,
: information_dispersion
}
( ) -> :
(entities) >= :
\
self
self
def
compute_treewidth
self, subgraph: nx.DiGraph
int
"""Estimate graph treewidth (NP-hard; use heuristic)."""
if
len
0
return
0
for
in
return
max
if
else
0
def
synthesize_query_with_complexity
self,
target_treewidth: int = 3 ,
information_dispersion: float = 0.7
Dict
"""
Generate query with target topological complexity.
Args:
target_treewidth: Desired graph complexity (higher = harder routing)
information_dispersion: Fraction of facts in different documents (0-1)
Returns:
task: {question, gold_facts, required_searches, optimal_path}
"""
min
2
len
self
list
self
self
self
if
self
for
in
if
3
for
in
if
not
in
for
in
self
'relation'
'connects_to'
f"{source} {relation} {target} "
max
1
len
max
1
int
len
self
for
in
range
len
self
1
if
self
return
'question'
'gold_facts'
'document_assignments'
'required_entities'
'treewidth'
'dispersion'
def
_generate_question
self, entities: List [str ], facts: List [str ]
str
"""Generate natural language question from entities and facts."""
if
len
2
return
f"What is the connection between {entities[0 ]} and {entities[-1 ]} ? "
f"List all intermediate steps."
return
f"Describe the relationships for: {', ' .join(entities)} "
Step 2: Tool-augmented learning class ToolAugmentedConstraintRepresentation :
"""Convert facts into tool-resolvable constraints."""
def __init__ (self, available_tools: Dict [str , callable ] ):
"""
Args:
available_tools: Dict of tool_name -> tool_function
e.g., {search_web, get_entity_facts, route_query}
"""
self .tools = available_tools
def convert_fact_to_tool_constraint (
self,
fact: str
) -> Dict :
"""
Convert fact into tool call constraint.
Example:
Fact: "Alice works at Acme Corp"
Constraint: {tool: "get_entity_facts", entity: "Alice", expected: "Acme Corp"}
"""
parts = fact.split()
if "connects" in fact.lower() or "relationship" in fact.lower():
entity1, entity2 = parts[0 ], parts[-1 ]
constraint = {
'type' : 'entity_relationship' ,
'entity_1' : entity1,
'entity_2' : entity2,
'required_tool' : 'get_entity_relationship' ,
'expected_relation' : fact
}
else :
entity = parts[0 ]
property_val = ' ' .join(parts[1 :])
constraint = {
'type' : 'entity_property' ,
'entity' : entity,
'property' : property_val,
'required_tool' : 'get_entity_facts' ,
'expected_value' : property_val
}
return constraint
def create_tool_sequence (self, task: Dict ) -> List [Dict ]:
"""
Create sequence of tool calls needed to resolve task.
Returns:
tool_sequence: List of {tool_name, arguments, expected_output}
"""
tool_sequence = []
for fact in task['gold_facts' ]:
constraint = self .convert_fact_to_tool_constraint(fact)
tool_call = {
'tool' : constraint['required_tool' ],
'arguments' : {
k: v for k, v in constraint.items()
if k not in ['type' , 'required_tool' , 'expected_relation' , 'expected_value' ]
},
'expected_output' : constraint.get('expected_relation' , constraint.get('expected_value' ))
}
tool_sequence.append(tool_call)
return tool_sequence
Step 3: Atomic skill learning in simulation class AtomicSkillTrainer :
"""Train fundamental search skills in simulation."""
def __init__ (
self,
model,
optimizer,
simulated_environment: dict
):
self .model = model
self .optimizer = optimizer
self .env = simulated_environment
def train_intent_grounding (
self,
tasks: List [Dict ],
num_steps: int = 1000
) -> float :
"""
Train skill: ground natural language intent into API calls.
Task: Given question, predict correct tool and arguments.
"""
total_loss = 0.0
for step in range (num_steps):
task = random.choice(tasks)
question = task['question' ]
tool_sequence = task['tool_sequence' ]
if not tool_sequence:
continue
first_tool = tool_sequence[0 ]
grounding_prompt = f"Question: {question} \n\nPredicted next search:"
predicted_grounding, log_probs = self .model.generate_with_logprobs(
grounding_prompt, max_tokens=100
)
is_correct = self ._match_grounding(
predicted_grounding,
first_tool['tool' ]
)
reward = 1.0 if is_correct else 0.0
loss = -log_probs.mean() * reward
self .optimizer.zero_grad()
loss.backward()
self .optimizer.step()
total_loss += loss.item()
return total_loss / num_steps
def train_hierarchical_planning (
self,
tasks: List [Dict ],
num_steps: int = 1000
) -> float :
"""
Train skill: decompose multi-step questions into tool sequence.
Task: Given question and facts, predict tool call order.
"""
total_loss = 0.0
for step in range (num_steps):
task = random.choice(tasks)
question = task['question' ]
tool_sequence = task['tool_sequence' ]
planning_prompt = f"Question: {question} \n\nPlan the search steps:"
predicted_plan, log_probs = self .model.generate_with_logprobs(
planning_prompt, max_tokens=200
)
num_correct = self ._score_plan(predicted_plan, tool_sequence)
reward = num_correct / max (1 , len (tool_sequence))
loss = -log_probs.mean() * reward
self .optimizer.zero_grad()
loss.backward()
self .optimizer.step()
total_loss += loss.item()
return total_loss / num_steps
def _match_grounding (self, prediction: str , expected_tool: str ) -> bool :
"""Check if prediction matches expected tool."""
return expected_tool.lower() in prediction.lower()
def _score_plan (self, prediction: str , expected_sequence: List [Dict ] ) -> int :
"""Count correctly ordered tools in prediction."""
correct = 0
for tool_dict in expected_sequence:
if tool_dict['tool' ] in prediction:
correct += 1
return correct
Step 4: Environment interaction stage class LongHorizonSearchRL :
"""RL training with actual environment interaction."""
def __init__ (
self,
model,
optimizer,
environment,
max_steps: int = 30
):
self .model = model
self .optimizer = optimizer
self .env = environment
self .max_steps = max_steps
def generate_trajectory (
self,
task: Dict ,
temperature: float = 0.7
) -> Dict :
"""
Generate trajectory by interacting with environment.
Returns:
trajectory: {question, steps, observations, reward, success}
"""
question = task['question' ]
trajectory = {
'question' : question,
'steps' : [],
'observations' : [],
'success' : False
}
current_state = question
discovered_facts = set ()
for step in range (self .max_steps):
prompt = f"Question: {question} \nCurrent findings: {current_state} \n\nNext action:"
action, log_probs = self .model.generate_with_logprobs(
prompt, max_tokens=50 , temperature=temperature
)
trajectory['steps' ].append({
'action' : action,
'log_probs' : log_probs
})
observation = self .env.execute_action(action)
trajectory['observations' ].append(observation)
current_state = f"{current_state} \n{observation} "
for fact in task['gold_facts' ]:
if fact in observation:
discovered_facts.add(fact)
if len (discovered_facts) == len (task['gold_facts' ]):
trajectory['success' ] = True
break
trajectory['num_facts_found' ] = len (discovered_facts)
trajectory['reward' ] = 1.0 if trajectory['success' ] else 0.5 * (len (discovered_facts) / len (task['gold_facts' ]))
return trajectory
def update_from_trajectory (self, trajectory: Dict ):
"""Update policy from trajectory."""
total_loss = 0.0
for step in trajectory['steps' ]:
log_probs = step['log_probs' ]
reward = trajectory['reward' ]
loss = -log_probs.mean() * reward
self .optimizer.zero_grad()
loss.backward()
torch.nn.utils.clip_grad_norm_(self .model.parameters(), 1.0 )
self .optimizer.step()
total_loss += loss.item()
return total_loss / len (trajectory['steps' ])
Step 5: Staged training pipeline def train_redsearcher_staged (
model,
corpus: List [str ],
entity_graph,
optimizer,
num_task_synthesis_iter: int = 500 ,
num_skill_steps: int = 5000 ,
num_env_steps: int = 10000 ,
device: str = 'cuda'
):
"""
Full REDSearcher training: synthesis → skills → environment.
"""
print ("Stage 1: Task Synthesis" )
synthesizer = DualConstraintedTaskSynthesis(corpus, entity_graph)
tool_converter = ToolAugmentedConstraintRepresentation({})
tasks = []
for i in range (num_task_synthesis_iter):
treewidth = (i % 5 ) + 1
dispersion = 0.5 + 0.3 * (i % 10 ) / 10
task = synthesizer.synthesize_query_with_complexity(
target_treewidth=treewidth,
information_dispersion=dispersion
)
task['tool_sequence' ] = tool_converter.create_tool_sequence(task)
tasks.append(task)
print (f" Generated {len (tasks)} tasks" )
print ("Stage 2: Atomic Skill Training" )
skill_trainer = AtomicSkillTrainer(model, optimizer, {})
loss_grounding = skill_trainer.train_intent_grounding(tasks, num_skill_steps // 2 )
loss_planning = skill_trainer.train_hierarchical_planning(tasks, num_skill_steps // 2 )
print (f" Grounding loss: {loss_grounding:.4 f} " )
print (f" Planning loss: {loss_planning:.4 f} " )
print ("Stage 3: Environment Interaction" )
env_trainer = LongHorizonSearchRL(model, optimizer, {}, max_steps=30 )
total_success = 0
for step in range (num_env_steps):
task = random.choice(tasks)
trajectory = env_trainer.generate_trajectory(task)
loss = env_trainer.update_from_trajectory(trajectory)
if trajectory['success' ]:
total_success += 1
if (step + 1 ) % 1000 == 0 :
success_rate = total_success / (step + 1 )
print (f" Step {step + 1 } : Success rate={success_rate:.2 %} " )
return model
Practical Guidance When to use : Multi-step information-seeking agents; questions requiring 10+ search steps; domains with clear document retrieval
treewidth_range : 1-5 (complexity)
information_dispersion : 0.4-0.9 (sparsity)
max_steps : 20-40 (trajectory length)
skill_training_ratio : Allocate steps 40% grounding, 40% planning, 20% integration
Systematic curriculum from simple to complex
Staged training reduces expensive environment calls
Atomic skills enable transfer across domains
Long-horizon support (30+ steps)
Too much task complexity too soon → exploration failure
Skill training too brief → weak foundations
Not validating facts are actually retrievable
Environment cost not amortized enough
Scaling : Simulation environment enables large-scale training; real interaction only for final polish.
Reference Paper: https://arxiv.org/abs/2602.14234
Related work: Information retrieval, long-horizon planning, RL for agents
Benchmarks: Humanity's Last Exam, BrowseComp, custom search tasks