Skip to content

[RLlib] Pass the documented argument names to on_offline_eval_runners_recreated - #67770

Merged
pseudo-rnd-thoughts merged 1 commit into
masterfrom
doc-1926-rllib-offline-eval-callback-kwargs
Nov 6, 2026
Merged

pseudo-rnd-thoughts merged 1 commit into
masterfrom
doc-1926-rllib-offline-eval-callback-kwargs

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Algorithm._run_one_offline_evaluation fires the on_offline_eval_runners_recreated callback after it restores offline evaluation runners. It passes env_runner_group= and env_runner_indices=. But RLlibCallback.on_offline_eval_runners_recreated declares offline_eval_runner_group and offline_eval_runner_indices as required keyword-only arguments. The AlgorithmConfig.callbacks() docs point callable callbacks to that signature too. So any callback that follows the documented signature raises TypeError when offline evaluation runners are restored:

TypeError: OfflineEvalRunnersRecreatedCallback.on_offline_eval_runners_recreated() missing 2 required keyword-only arguments: 'offline_eval_runner_group' and 'offline_eval_runner_indices'

This PR passes the documented argument names. This call site is the only place RLlib fires the callback, and the only other implementation, the _MultiCallbacks container in callbacks/utils.py, takes **kwargs. Ray 2.59.0 has the same bug.

This PR also adds test_on_offline_eval_runners_recreated_callback to callbacks/tests/test_callbacks_on_algorithm.py. The test calls _run_one_offline_evaluation on a stand-in algorithm whose offline evaluation runners report two restored runners. It checks that both an RLlibCallback subclass and a callable, each written against the documented signature, receive the runner group and indices. It doesn't need offline data or crashing runners, so it runs in seconds.

I found this while fixing the on_offline_eval_runners_recreated docstring example in #67762.

Related issues

Related to #67762.

Additional information

Not a duplicate. I searched open PRs for on_offline_eval_runners_recreated and found only #67762, which changes that hook's docstring example, not this call site.

Tests run

These ran in a Python 3.12 virtualenv with ray[rllib]==2.59.0 and torch, with ray/rllib linked to this branch's source:

  • The new test, before the fix: it fails with the TypeError above.
  • pytest python/ray/rllib/callbacks/tests/test_callbacks_on_algorithm.py, after the fix: "3 passed in 68.47s." That includes the existing test_on_env_runners_recreated_callback and test_on_init_and_checkpoint_loaded.
  • pre-commit run --files on both changed files: all hooks pass.

AI assistance (Claude Code) was used for this PR.

🤖 Generated with Claude Code

…_recreated

`Algorithm._run_one_offline_evaluation` fired the
`on_offline_eval_runners_recreated` callback with `env_runner_group=` and
`env_runner_indices=`. `RLlibCallback.on_offline_eval_runners_recreated`
declares `offline_eval_runner_group` and `offline_eval_runner_indices` as
required keyword-only arguments, so any callback that follows the
documented signature raised `TypeError` when offline evaluation runners
were restored. Pass the documented names and add a regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman added the rllib RLlib related issues label Nov 3, 2026
@dstrodtman
dstrodtman marked this pull request as ready for review November 3, 2026 21:00
@dstrodtman
dstrodtman requested a review from a team as a code owner November 3, 2026 21:00
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Nov 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the _run_one_offline_evaluation method in Algorithm to pass offline_eval_runner_group and offline_eval_runner_indices instead of env_runner_group and env_runner_indices to the callback. It also introduces a new callback class OfflineEvalRunnersRecreatedCallback and a corresponding unit test to verify that the offline evaluation runner recreation callback is correctly triggered with the updated arguments. There are no review comments, so I have no feedback to provide.

@pseudo-rnd-thoughts

Copy link
Copy Markdown
Member

LGTM

@pseudo-rnd-thoughts
pseudo-rnd-thoughts merged commit 0a27c58 into master Nov 6, 2026
7 checks passed
@pseudo-rnd-thoughts
pseudo-rnd-thoughts deleted the doc-1926-rllib-offline-eval-callback-kwargs branch November 6, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests rllib RLlib related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants