AS AgentScopeAPI 手册 / API Reference

TrainingRunner

public class TrainingRunner
源码Source io/agentscope/core/training/runner/TrainingRunner.java:83–292

Training 运行器,对智能体行为进行评测、追踪与可观测性分析。位于 io.agentscope.core.training.runner 包。核心成员包括 start、stop、commit、isRunning、getConfig、builder。

Training Runner - Training Process Controller

Responsible for:

  • Intercepting Agent requests and determining if they should be used for training

  • Replacing ChatClient to Trinity backend

  • Collecting trace data

  • Calculating rewards and calling feedback API

  • Periodically calling commit API to trigger training

Usage example:

`// Method 1: Using sampling rate strategy
TrainingRunner runner = TrainingRunner.builder()
.trinityEndpoint("http://localhost:8080")
.modelName("/path/to/model")
.selectionStrategy(SamplingRateStrategy.of(0.1)) // 10% sampling rate
.rewardCalculator(agent -> 0.0) // Implement custom reward logic
.commitIntervalSeconds(300) // Commit every 5 minutes
.build();

// Method 2: Using explicit marking strategy
TrainingRunner runner = TrainingRunner.builder()
.trinityEndpoint("http://localhost:8080")
.modelName("/path/to/model")
.selectionStrategy(ExplicitMarkingStrategy.create()) // User manually marks
.rewardCalculator(agent -> {
// Custom reward calculation logic
return 1.0;
})
.build();

// Method 3: Using custom RewardCalculator class
TrainingRunner runner = TrainingRunner.builder()
.trinityEndpoint("http://localhost:8080")
.modelName("/path/to/model")
.selectionStrategy(SamplingRateStrategy.of(0.1))
.rewardCalculator(new CustomRewardCalculator()) // Implement RewardCalculator interface
.build();

// Start training runner
runner.start();

// Users use Agent normally (transparent)
agent.call(msg).block();

// Stop training
runner.stop();
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
TrainingRunner的构建器。
Builder for TrainingRunner

方法摘要Method Summary

方法Method说明Description
public synchronized void start()
synchronized
执行启动相关操作。
Start training runner
public synchronized void stop()
synchronized
执行停止相关操作。
Stop training runner
public Mono<Void> commit()
返回提交。
Manually trigger commit
public boolean isRunning()
判断是否运行中。
Returns whether the running.
public TrainingConfig getConfig()
获取配置。
Returns the config.
public static Builder builder()
static
返回构建器实例。
Returns the builder.

方法详情Method Detail

start

public synchronized void start()
synchronized

执行启动相关操作。

Start training runner

源码Source io/agentscope/core/training/runner/TrainingRunner.java:115–134

stop

public synchronized void stop()
synchronized

执行停止相关操作。

Stop training runner

源码Source io/agentscope/core/training/runner/TrainingRunner.java:139–169

commit

public Mono<Void> commit()

返回提交。

Manually trigger commit

返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/core/training/runner/TrainingRunner.java:174–180

isRunning

public boolean isRunning()

判断是否运行中。

Returns whether the running.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/training/runner/TrainingRunner.java:216–218

getConfig

public TrainingConfig getConfig()

获取配置。

Returns the config.

返回Returns TrainingConfig
返回TrainingConfig。Returns training config.
源码Source io/agentscope/core/training/runner/TrainingRunner.java:220–222

builder

public static Builder builder()
static

返回构建器实例。

Returns the builder.

返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingRunner.java:224–226

嵌套类详情Nested Class Detail

Builder

public static class Builder

TrainingRunner的构建器。位于 io.agentscope.core.training.runner 包。核心成员包括 config、trinityEndpoint、modelName、selectionStrategy、rewardCalculator、commitIntervalSeconds。

Builder for TrainingRunner

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.