# Best practice for using \`get\_action\` and \`log\_action\` together?

**URL:** <https://discuss.ray.io/t/best-practice-for-using-get-action-and-log-action-together/3286>\
**Category:** RLlib\
**Created:** [August 19, 2021, 2:48am UTC](https://discuss.ray.io/t/best-practice-for-using-get-action-and-log-action-together/3286 "2021-08-19T02:48:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviskarkc10](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aviskarkc10/32/1231_2.png) [@aviskarkc10](https://discuss.ray.io/u/aviskarkc10)\
**Post date:** [August 19, 2021, 2:48am UTC](https://discuss.ray.io/t/best-practice-for-using-get-action-and-log-action-together/3286/1 "2021-08-19T02:48:34Z")

</div>

I have been using `get_action` and `log_action` based on the comment here:

> <https://github.com/ray-project/ray/blob/master/rllib/examples/serving/cartpole_client.py#L34>

When using these two functions together, should I be using two different episodes or is it all right if both are called within the same episode?

---

<div class="post-metadata">

**Author:** ![michaelzhiluo](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@michaelzhiluo](https://discuss.ray.io/u/michaelzhiluo)\
**Post date:** [August 19, 2021, 9:18am UTC](https://discuss.ray.io/t/best-practice-for-using-get-action-and-log-action-together/3286/2 "2021-08-19T09:18:39Z")

</div>

They should be within the same episode and timestep. `log_action` takes action as input, which should be ideally retrieved via `get_action`.
