agentscope-extensions-training plugs a Trinity-style training backend into AgentScope: it samples production traffic, collects traces, computes rewards, and periodically commits training jobs — closing the loop.
When to use
- You run Trinity (or a compatible service) as the training store.
- You want to use live traffic for reinforcement learning or online fine-tuning.
- You want the training pipeline to be transparent to the Agent’s callers.
Add the dependency
Quickstart
Selection strategies
SamplingRateStrategy.of(0.1): random sampling at the given rate.ExplicitMarkingStrategy.create(): only marked requests are sampled.- Or implement
TrainingSelectionStrategyfor custom behavior.
Reward calculation
rewardCalculator is a Function<AgentBase, Double>, invoked once per sampled trajectory:
- A lambda — heuristics like answer length, tool-call count, etc.
- A custom class implementing
RewardCalculatorfor richer metrics.
How it works
- After
runner.start(), requests go throughTrainingRouter:- sampled → routed to the Trinity store, traces collected;
- not sampled → original model is used, no side effects.
- Sampled trajectories invoke the reward calculator and feedback through
TrinityClient.feedback(...). - Every
commitIntervalSeconds,commit(...)triggers a training job.
runner.stop() shuts down timers and connection pools cleanly.
Key configuration
Pairs well with Studio
AttachStudioMessageHook simultaneously and you can see in Studio which sessions get sampled and how rewards were computed.