MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp

github.com/InternLM/InternBootcamp @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
22,345 symbols 91,234 edges 4,234 files ⚖ Apache-2.0 12,085 documented · 54% updated 17d ago★ 3503 open issues

Browse by type

Functions 18,522 Types & classes 3,617 Endpoints 206
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

InternAgentHarness

🎉 InternAgentHarness technical report: InternAgentHarness: A Scalable Synthetic Environment for Enhancing LLM Agentic Abilities

🎉 InternBootcamp v1 的技术报告已被 WAICA 2026 接收!

📄 技术报告:InternBootcamp Technical Report: Boosting LLM Reasoning with Verifiable Task Scaling

📦 技术报告对应代码版本:InternBootcamp v1

总体概要

InternAgentHarness (InternBootcamp) 是一个面向大语言模型智能体训练与评测的可扩展合成环境框架。

它并不只关注一次性的 benchmark 分数,而是为智能体构建可执行、可交互、可验证的任务环境。模型可以在真实的工具调用、状态反馈、多轮交互和奖励信号中持续学习与改进。

在 InternAgentHarness 中,不同类型的智能体任务会被统一封装为可训练的环境实例。每个任务由四个核心部分组成:

  • 任务提示生成:构造任务目标、初始状态和输入上下文
  • 工具执行:为智能体提供可调用、可验证的外部工具
  • 交互控制:管理模型与环境之间的多轮通信流程
  • 奖励计算:根据任务结果和中间过程提供可训练的反馈信号

通过这套统一接口,科研工具调用、路径规划、金融推理、游戏决策、视觉任务等不同场景都可以在同一流程下完成运行、记录、训练和评测。

InternAgentHarness Overview

BootCampCLI

InternAgentHarness 同时提供 BootCampCLI,用于将任务配置自动转换为可运行的智能体交互流程。

用户可以先在本地调试单个任务,再将相同配置扩展到:

  • 批量轨迹采集
  • 监督微调数据过滤
  • 强化学习 rollout
  • 测试集评测
  • 失败样例分析

每次运行都会记录完整的交互轨迹,包括模型回复、工具调用、环境反馈、奖励结果和最终答案。这些记录便于后续复现、训练、调试和环境迭代。

适用场景

InternAgentHarness 适用于希望进行以下工作的研究者和开发者:

  • 构建智能体训练环境
  • 评测模型的工具使用能力
  • 收集多轮交互轨迹并改进任务设计

它将“评测、数据生成、训练、再评测”连接成一个闭环,帮助用户更高效地提升大语言模型在复杂任务中的规划、工具使用、反馈修正和决策能力。

任务示例

Task Examples

InternAgentHarness 提供了一组覆盖不同能力维度的智能体任务环境,用于评测和训练大语言模型在复杂场景中的规划、工具调用、反馈修正和决策能力。这些任务并不是简单的问答数据,而是可执行、可交互、可验证的智能体环境。模型需要根据任务目标调用相应工具,观察环境反馈,并在多轮交互中持续调整策略。 例如:

  • Battery Design 中,智能体需要根据温度、能量和设计目标优化电池参数。
  • Bot Trajectory Planning 中,模型需要规划机械臂运动并避免碰撞。
  • Financial Prediction 中,模型需要结合财务数据和约束指标完成预测。
  • Texas Hold'em Game 中,模型需要基于牌局状态和对手信息进行决策。

通过这些多样化任务,InternAgentHarness 能够系统评估模型是否真正具备面向智能体应用的核心能力,包括理解任务约束、正确使用工具、处理中间反馈、完成长程决策以及输出可验证结果。

用户也可以基于相同接口扩展新的任务环境,将自定义场景接入统一的训练、评测和轨迹采集流程。

使用指南

这里是基于InternBootcampv1开发的InternAgentHarness,主要包含了针对具体专业性Bootcamp场景的multi-round toolcall的agentic RL 流程。

1. 架构概述

1.1 InternAgentHarness核心改进

InternAgentHarness 深入绑定了verl的multi-round toolcall的流程,通过SGLANG-rollout的state control,实现对专业场景的toolcall调用、reward计算、模型训练及推理

1.2 Multi-round Toolcall的实现原理

1.2.1 与Bootcampv1的差异

为了支持更复杂的Bootcamp任务,我们需要多轮工具调用来处理。

  1. 基于多轮工具调用的复杂推理任务,通常有两种形式:

(1)LLM-based workflow

prompt --> LLM rollout(decision) --> tooluse response --> LLM rollout(decision) --> tooluse response ...

(2)environment-based workflow

prompt --> LLM rollout --> tooluse --> env decision --> LLM rollout --> tooluse --> env decision ...

即,一个Bootcamp任务存在两种LLM与环境的交互形式

  1. 为什么要multi-round toolcall & multi-round toolcall很复杂:

(1)single-round toolcall & 多轮对话,本质上都可以refine成single-round的交互

(2)multi-round toolcall 的调用在RL framework中,需要async的调用,导致rollout逻辑会更加复杂

1.2.2 复杂Bootcamp的代码逻辑

  1. 一个需要多轮调用工具的Bootcamp流程:两种情况 toolcall or interaction-call ,以下统称toolcall

流程包含了:

(1)模型的prompt Design,workflow的整个流程;

prompt Design,在verl里体现为数据构造,对应包含data-source来明确task的类型,

生成这种数据的流程,在Bootcamp中,参考InternBootcampv1的对应思路;

(2)对应需要调用的tool的toollist tool的描述;

verl中, toollist,在toolconfig里填写,并且会在chat-template中基于对应mcp协议,拼接在chat-template里,

tool的config中,直接绑定了对应的tool的实现;

(3)调用的tool的实现逻辑,对应的io;

verl中,tool的调用,是通过执行execute,在SGLANG的rollout中对应调用的,

其中,SGLANG的rollout,会根据对应的state,对rollout过程进行控制,这些state包含了toolcall 和terminate等信号,

同时,在这里会计算每一轮的toolcall返回的中间过程reward;

SGLANG的rollout中,需要传入的参数包含了

  • 完整的workflow,即prompt、toollist等(这里很重要,因为previous sglang&verl版本中对rollout的传参控制中不包含toollist等内容);

(4)基于tool的io的返回,模型的multi-round rollout;

整体rollout结束后,会通过reward score 处计算最终的reward

(5)基于toolcall返回 or 基于模型判断 or 基于max-step 等条件,任务workflow的最终终止;

verl中,state中控制了流程的终止

2. 环境准备

2.1 安装依赖

2.1.1 安装InternBootcamp

git clone https://example.com/openinternbootcamp.git --recurse-submodules
cd openinternbootcamp
pip install -e ./
# verl install
pip install -e ./verl/
# openevolve install
pip install -e ./openevolve/
# 一键安装所有父和子仓库依赖
pip install -r requirements-editable.txt

2.2 系统架构设计

2.2.1 核心组件

  1. InstructionGenerator: 指令生成,负责prompt设计和数据流控制
  2. ToolManager: 工具管理,处理工具调用和执行
  3. RewardCalculator: 奖励计算
  4. Evaluator: 评估器,可以用于评测、rollout、bootcamp开发调试
  5. InteractionManager: 交互管理,处理用户输入输出

2.2.2 设计原则

  • 模块化: 各组件独立,便于维护和扩展
  • 可配置: 通过配置文件控制行为
  • 可扩展: 支持新工具和场景的快速接入

3. 核心组件开发与使用

3.1 指令生成器开发

3.1.1 功能职责

  • 完成任务生成和数据生成。

3.1.2 开发指南

继承基类BaseInstructionGenerator

示例: example_instruction_generator.py

若需生成数据,须继承BaseInstructionGenerator基类,并实现以下两个抽象方法:(若无需生成数据则将数据规范为以下对应格式即可,无需实现InstructionGenerator)

from internbootcamp.src.base_instruction_generator import BaseInstructionGenerator
from typing import Dict, Any, Optional
import random

class CustomInstructionGenerator(BaseInstructionGenerator):
    """自定义指令生成器"""

    def __init__(self, **kwargs):
        super().__init__()
        # 配置data_source,基类已如下实现,计算reward时会根据此信息匹配对应的RewardCalculator
        self.data_source = f"bootcamp/{self.__class__.__name__.replace('InstructionGenerator', '').lower()}"
        # 初始化自定义参数
        for key, value in kwargs.items():
            setattr(self, key, value)

    def case_generator(self) -> Dict[str, Any]:
        """
        生成任务案例,返回包含任务信息的字典

        Returns:
            Dict[str, Any]: 任务信息字典,包含ground_truth等关键信息;
            这个任务信息字典将作为对应RewardCalculator的_verify_correction方法和对应Tool的create方法的identity参数传入
        """
        # 实现任务生成逻辑
        # 例如:生成数学题目、电路参数等
        pass

    def prompt_func(self, identity: Dict[str, Any]) -> str:
        """
        根据任务信息生成提示语

        Args:
            identity (Dict[str, Any]): 任务信息字典

        Returns:
            str: 生成的提示词
        """
        # 实现提示语生成逻辑
        # 使用identity中的信息构建输入给语言模型的prompt
        pass

关键要点: - data_source属性用于标识数据来源,格式为"bootcamp/your_bootcamp_name" - case_generator()方法生成能用来唯一确定任务且验证候选答案的参数集,以字典格式返回 - prompt_func()方法根据任务参数生成提示词

实践建议: - Prompt模板:使用多个prompt模板,生成时随机选择,实现多样prompt - 题目变种:使用参数data_type参数控制题目变种类型,实现多样的题型与prompt

3.1.3 配置文件管理

示例: example_instruction_config.yaml

使用YAML配置文件来管理数据生成的参数和行为:

# custom_instruction_config.yaml
instruction_generators:
  # 基础配置组
  basic_config:
    config:
      min_value: 1
      max_value: 100
      operation_type: "simple"
    generation_ratio: 0.1  # 占总生成数据的40%,所有generation_ratio会自动归一化为比例(如0.4和0.6会分别分配40%和60%的样本数)

  # 高级配置组
  advanced_config:
    config:
      min_value: 50
      max_value: 500
      operation_type: "complex"
    generation_ratio: 0.7  # 占总生成数据的60%,无需手动保证所有ratio之和为1,系统会自动归一化

  # 带默认tool的配置组
  basic_config_w_tool:
    min_value: 1
      max_value: 100
      operation_type: "simple"
    generation_ratio: 0.1
    yaml_tool_path: "path/to/tool.yaml" # 工具配置文件路径

  # 带默认interaction的配置组
  basic_config_w_tool:
    min_value: 1
      max_value: 100
      operation_type: "simple"
    generation_ratio: 0.1
    yaml_interaction_path: "path/to/interaction.yaml" # 交互配置文件路径

# 全局配置
global_config:
  # 指令生成器类的完整路径
  class_name: "internbootcamp.bootcamps.your_bootcamp.your_instruction_generator.CustomInstructionGenerator"

  # 随机种子配置
  enable_random_seed: true
  default_seed: 999

  # 数据集划分配置
  default_split_samples:
    train: 10000
    test: 1000

  # 是否启用数据打乱
  shuffle: true

  # 是否生成parquet文件
  gen_parquet: false

配置说明: - instruction_generators: 定义多组配置,每组有不同的参数和生成比例 - global_config: 全局设置,包括类路径、随机种子、数据集划分、是否生成parquet格式数据等,也可于此配置tool或interaction config(全局配置会与单条generator配置合并) - generation_ratio: 控制每组配置生成数据的比例,自动归一化

3.1.4 数据生成操作

示例: example_multiturn_w_tool_grpo.sh

3.1.4.1 单个配置生成

例如以下命令

# data_generate.sh
#!/bin/bash
python -m internbootcamp.utils.data_generation \
    --instruction-config configs/your_instruction_config.yaml \
    --output-dir data/your_bootcamp/ \
    --tool-config configs/your_tool_config.yaml \ #全局配置,与单条配置合并
    --interaction-config configs/your_interaction_config.yaml \ #全局配置,与单条配置合并
    --split-samples train:10000,test:1000 \
    --shuffle \
    --global-config-overrides '{"gen_parquet": true}' \ #全局配置覆盖
    --no-tool \ #开启则不使用任何工具配置
    --no-interaction \ #开启则不使用任何交互配置

参数列表

参数名称 类型 必需 默认值 说明
--instruction-config str - 指令管理器配置文件路径,定义数据生成的核心逻辑
--output-dir str - 输出文件目录,生成的数据集将保存在此目录下
--tool-config str None 工具配置文件路径,相当于全局配置,生成时与单条配置合并(冲突时优先使用单条配置)
--interaction-config str None 交互配置文件路径,相当于全局配置,生成时与单条配置合并(冲突时优先使用单条配置)
--split-samples str None 数据集划分和样本数,格式为 train:10000,test:1000,val:500
--shuffle flag False 是否对生成的数据进行随机打乱
--gen_parquet flag True 是否生成parquet格式文件(除jsonl外)
--global-config-overrides str None 全局配置覆盖参数,JSON字符串格式,如 '{"enable_random_seed": true}'
--no-tool flag False 开启则不使用任何工具配置
--no-interaction flag False 开启则不使用任何交互配置
3.1.4.2 生成数据格式

执行脚本后会以split为后缀生成多个jsonl数据文件

{
    "data_source": "bootcamp/Example",
    "prompt": [
        {
            "content": "你是一位数学专家,擅长进行算术运算。\n\n任务:计算表达式 88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020 的结果,误差范围为 1e-4\n\n最终答案格式:请以``json\n{\n    \"result\": your_result\n}\n``格式返回结果,且在必要时使用科学计数法(如1e-4、2.5E+3)。\n\n计算建议:\n1. 请在合适的时机运用算术工具,如需要计算大数等自信程度不高计算时,以避免计算错误和无意义的工具调用。\n2. 若需要计算的表达式较长,请在实际计算开始前,先进行计算规划,以避免计算错误和无意义的工具调用。\n下面请开始计算。",
            "role": "user"
        }
    ],
    "reward_model": {
        "ground_truth": {
            "expression": "88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020",
            "expected_result": 2146993745.4955528,
            "tolerance": "1e-4"
        },
        "style": "rule"
    },
    "extra_info": {
        "tools_kwargs": {

        },
        "need_tools_kwargs": false,
        "index": 102,
        "split": "test",
        "generator_name": "medium_arithmetic_w_interaction",
        "interaction_kwargs": {
            "name": "example_interaction",
            "identity": {
                "expression": "88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020",
                "expected_result": 2146993745.4955528,
                "tolerance": "1e-4"
            }
        }
    }
}
3.1.4.3 批量数据生成

示例: batch_data_generation.py

现支持批量并行数据生成:

# 批量数据生成
python -m internbootcamp.utils.batch_data_generation \
    --bootcamp-registry configs/bootcamp_registry.jsonl \ # Bootcamp注册表
    --max-workers 8 \ # 最大并行进程数
    --output-dir data/batch_generated/ \
    --split-samples train:1000,test:100 \ #每个Bootcamp配置生成1000个训练样本和100个测试样本
    --concat-files \
    --continue-on-error

bootcamp注册表作为批量生成配置文件(bootcamp_registry.jsonl): 单条注册表数据结构:

{"instruction_config_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_instruction_config.yaml", "data_source": "bootcamp/YourBootcamp", "yaml_tool_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_tool_config.yaml", "yaml_interaction_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_interaction_config.yaml", "reward_calculator_class": "internbootcamp.bootcamps.your_bootcamp.your_reward_calculator.YourRewardCalculator"}

参数列表

参数名称 类型 必需 默认值 说明
--bootcamp-registry str - Bootcamp注册表文件路径,jsonl格式,每条记录包含一个bootcamp的配置信息
--max-workers int min(16, CPU核心数) 最大并行工作进程数,自动限制在CPU核心数范围内
--continue-on-error flag False 遇到

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 15,730
Class 3,617
Function 2,792
Route 206

Languages

Python100%
TypeScript1%

Modules by API surface

internbootcamp/bootcamps/holdem_bootcamp/holdem_server.py71 symbols
internbootcamp/bootcamps/flangeplane_bootcamp/utils/cadlib/curves.py65 symbols
verl/verl/single_controller/ray/base.py64 symbols
verl/tests/workers/rollout/rollout_sglang/test_http_server_engine.py61 symbols
verl/verl/protocol.py59 symbols
verl/verl/experimental/vla/models/openvla_oft/modeling_prismatic.py54 symbols
internbootcamp/bootcamps/escape_bootcamp/escape_server.py54 symbols
verl/verl/workers/megatron_workers.py51 symbols
verl/verl/utils/activation_offload.py51 symbols
verl/verl/workers/fsdp_workers.py50 symbols
verl/verl/trainer/ppo/core_algos.py47 symbols
verl/tests/trainer/ppo/test_metric_utils_on_cpu.py45 symbols

For agents

$ claude mcp add InternBootcamp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page