Skip to content

Custom Policy Backend Support #6290

Description

@kakky-hacker

Is your feature request related to a problem? Please describe.

Currently, it is difficult to integrate a custom reinforcement learning backend into ML-Agents without modifying the core package.

The IPolicy implementations are effectively internal, and there is no official extension point to inject a custom policy from an external package. As a result, users who want to experiment with alternative backends (e.g., calling a reinforcement learning implementation from a native DLL via FFI, instead of using the built-in Python-based workflow) are forced to maintain a fork or directly modify core classes such as BehaviorParameters.

This creates maintenance overhead and makes it harder to keep up with upstream updates.

Describe the solution you'd like

I would like to have a pluggable policy interface that allows external packages to provide custom IPolicy implementations without modifying ML-Agents core code.

For example, this could be achieved by:

  • Introducing a factory or registry mechanism (e.g., IPolicyFactory)
  • Allowing BehaviorParameters to delegate policy creation to a registered provider
  • Supporting external packages to register custom policy implementations

This would make it possible to swap out the default policy backend while still using ML-Agents’ existing sensor and environment systems.

Describe alternatives you've considered

  • Forking ML-Agents and modifying BehaviorParameters directly
    → Works, but introduces long-term maintenance issues

  • Implementing the entire agent loop outside of ML-Agents
    → Avoids modification, but loses integration with sensors, actuators, and existing tooling

Both approaches are less maintainable compared to having an official extension point.

Additional context

I am currently working on integrating a native reinforcement learning backend (implemented by Rust and tch-rs) and would like to use it as a drop-in replacement for the default policy.

Having a pluggable policy interface would make this integration clean and reusable, and could also benefit other users exploring alternative ML backends.

I would be happy to contribute a PR if this direction aligns with the project’s design goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestIssue contains a feature request.staleIssues that have been idle for a while. Automatically closed by a bot if idle for too long.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions