scicode_tool_use Harness 运行 SciCode 专用的顺序工具使用流程,可选带代码解释器执行(官网 scicode-bench.github.io)。仅支持 host_process Environment。
它把被测 model 适配到 AgentCompass 的 PreparedTask -> RunResult 契约:按题目分步生成代码,tool_use 模式下调用 code_interpreter 执行并回灌结果,最后回收轨迹与生成代码。被测 model 凭据由命令行 --model-* 传入,支持 openai-chat 与 openai-responses。
工作原理
- 生成模式:
mode=naive直接分步生成,tool_use则在每步内跑工具循环;tool_names选启用的工具(默认code_interpreter),tool_use_max_loops限每步循环数,with_background决定分步提示词是否带步骤后台。 - 代码执行:
code_interpreter在code_workdir里执行,单次超时code_timeout_seconds,execution_preamble在生成代码前先跑,python_binary指定解释器(默认当前解释器)。 - 可选 sandbox:给出
sandbox_url时把代码执行下放到 sandbox 服务,sandbox_memory_limit_mb限内存,sandbox_max_retries/sandbox_retry_delay_seconds/sandbox_api_timeout_seconds控制 API 重试与超时,sandbox_no_proxy设置免代理。 - 回收结果:把逐步生成与执行记录规整成轨迹,返回
RunResult。
参数
通过--harness-params '{...}' 传入一段 JSON;也可写进 --config 指定的 YAML 的 harness.params 块,同名项以命令行为准(深度合并覆盖)。合并与优先级见 Harness 概览。
参数总览
| 参数 | 类型 | 默认值 | 可选值 / 取值 | 说明 |
|---|---|---|---|---|
mode | 字符串 | tool_use | naive / tool_use | 生成模式。 |
tool_names | 列表 | [“code_interpreter”] | — | 启用的工具列表。 |
tool_use_max_loops | 整数 | 15 | ≥ 1 | 每步允许的最大工具使用循环数。 |
with_background | 布尔值 | true | true / false | 分步提示词是否包含步骤后台。 |
code_timeout_seconds | 整数 | 180 | ≥ 1 | 单次 code_interpreter 执行超时(秒)。 |
code_workdir | 字符串 | .agentcompass/scicode_tool_use | — | code_interpreter 的本地工作目录。 |
execution_preamble | 字符串 | "" | — | 生成代码前额外执行的代码。 |
python_binary | 字符串 | "" | — | Harness 使用的 Python 可执行文件(默认取当前解释器)。 |
sandbox_url | 字符串 | "" | — | 可选的 sandbox 服务 URL。 |
sandbox_no_proxy | 字符串 | "" | — | 可选的 sandbox no_proxy 值。 |
sandbox_memory_limit_mb | 整数 | 1024 | ≥ 1 | sandbox 代码执行内存上限(MB)。 |
sandbox_max_retries | 整数 | 3 | ≥ 1 | sandbox API 失败后的重试次数。 |
sandbox_retry_delay_seconds | 浮点数 | 2.0 | ≥ 0 | sandbox API 重试间隔(秒)。 |
sandbox_api_timeout_seconds | 整数 | 30 | ≥ 1 | sandbox API 请求超时(秒)。 |
运行示例
- 默认配置
- 自定义参数
本地
code_interpreter、tool_use 模式。输出
Harness 为每个任务返回RunResult:逐步生成与执行的轨迹、最终代码与执行状态。单任务详情与聚合指标由 Benchmark 写入 results/<benchmark>/<model>/<run>/(详见 结果)。