# How to access the policy object in the on\_train\_result callback of Ray RLlib? The callback signature is on\_train\_result(self, \*, algorithm, result, \*\*kwargs)

**URL:** <https://discuss.ray.io/t/how-to-access-the-policy-object-in-the-on-train-result-callback-of-ray-rllib-the-callback-signature-is-on-train-result-self-algorithm-result-kwargs/22093>\
**Category:** RLlib\
**Created:** [March 20, 2025, 9:45am UTC](https://discuss.ray.io/t/how-to-access-the-policy-object-in-the-on-train-result-callback-of-ray-rllib-the-callback-signature-is-on-train-result-self-algorithm-result-kwargs/22093 "2025-03-20T09:45:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZanhaPeng](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/zanhapeng/32/7699_2.png) [@ZanhaPeng](https://discuss.ray.io/u/ZanhaPeng)\
**Post date:** [March 20, 2025, 9:45am UTC](https://discuss.ray.io/t/how-to-access-the-policy-object-in-the-on-train-result-callback-of-ray-rllib-the-callback-signature-is-on-train-result-self-algorithm-result-kwargs/22093/1 "2025-03-20T09:45:43Z")

</div>

code is as followed:  
@override(DefaultCallbacks)  
def on\_train\_result(self, \*, algorithm, result, \*\*kwargs):  
iteration = result.get(“training\_iteration”, 0)  
policy\_map = algorithm.workers.local\_worker().policy\_map  
policy = policy\_map.get(“default\_policy”)  
config = (  
PPOConfig()  
.api\_stack(enable\_rl\_module\_and\_learner=True, enable\_env\_runner\_and\_connector\_v2=True)  
.callbacks(IntrinsicRewardCallbacks)
