Hi!
At JetBrains, we are developing a code execution backend (currently called IDEGym) specifically tailored for reinforcement learning. We are planning to open source it in the near future and wanted to suggest a possible integration.
Our tool is currently focused on supporting agentic coding training for a variety of complex tasks. For example, it can handle SWE-bench–style tasks where rewards are derived from executing comprehensive test suites, as well as environment setup tasks where rewards come from successfully building or analyzing a project.
We were able to adapt the OpenEnv protocol and communication approach to run OpenEnv environments on our Kubernetes cluster using our own orchestrator.
I'm attaching an example of code showing how we communicate with an OpenEnv environment using our client. Ideally, we would love to build a proper integration, but before submitting a PR we wanted to discuss some details with you. Since we are working on Kubernetes integration, some of our solutions might also be relevant for you, especially given your plans to support k8s and the discussion around the role of an orchestrator in issue #199.
Is there any active work on Kubernetes support or any existing ideas regarding the design of the provider? I have reviewed issue #199 , but did not find any additional information beyond that.
P.s.: The example is purely for demonstration of implementation since IDEGym is not open sourced yet, but I hope soon you will be able to play with it.
P.p.s: If needed, I can open RFC -- not sure if the question on the level of it or not.
"""
Example: Running an OpenEnv echo_env through the IDEGym orchestrator.
This example uses the echo_env from https://huggingface.co/spaces/openenv/echo_env
— a minimal OpenEnv environment that echoes back every message you send.
It is a good smoke-test for the whole IDEGym + OpenEnv integration.
OpenEnv environments communicate over a persistent WebSocket connection instead
of IDEGym REST API. The orchestrator proxies the WebSocket so the user-facing
workflow is identical to other IDEGym server types.
Environment variables
---------------------
IDEGYM_AUTH_USERNAME - orchestrator basic-auth username
IDEGYM_AUTH_PASSWORD - orchestrator basic-auth password
"""
from asyncio import run
from os import environ as env
from dotenv import load_dotenv
from echo_env import EchoAction, EchoEnv
from idegym.api.auth import BasicAuth
from idegym.api.orchestrator.servers import ServerKind
from idegym.client.client import IdeGYMClient
from idegym.utils.logging import get_logger
from kubernetes_asyncio.client import V1ResourceRequirements
load_dotenv()
logger = get_logger(__name__)
# Docker image built from https://huggingface.co/spaces/openenv/echo_env
ECHO_ENV_IMAGE_TAG = ...
# IdeGYM orchestrator running on k8s accessible through this URL
ORCHESTRATOR_URL = "http://idegym.test/"
async def main():
async with IdeGYMClient(
orchestrator_url=ORCHESTRATOR_URL,
name="echo-env-client",
namespace="idegym",
auth=BasicAuth(
username=env.get("IDEGYM_AUTH_USERNAME"),
password=env.get("IDEGYM_AUTH_PASSWORD"),
),
) as client:
async with client.with_server(
image_tag=ECHO_ENV_IMAGE_TAG,
server_name="echo-env-server",
server_kind=ServerKind.OPENENV,
# echo_env runs uvicorn on port 8000 (see CMD in the Dockerfile).
service_port=8000,
container_port=8000,
namespace="idegym",
runtime_class_name="gvisor",
resources=V1ResourceRequirements(
requests={"cpu": "500m", "memory": "512Mi"},
limits={"cpu": "1", "memory": "1Gi"},
),
server_start_wait_timeout_in_seconds=120,
) as server:
logger.info(f"Server started (id={server.server_id})")
# server.openenv_url is the base URL passed to EchoEnv.
# It resolves to: <orchestrator>/api/ws-forward/<client_id>/<server_id>
# EchoEnv (via EnvClient) appends /ws when it opens the WebSocket.
logger.info(f"openenv_url: {server.openenv_url}")
with EchoEnv(base_url=server.openenv_url) as echo:
# Start a new episode — returns the initial observation.
reset_result = echo.reset()
logger.info(
event="reset",
echoed_message=reset_result.observation.echoed_message,
episode_id=reset_result.observation.metadata.get("episode_id"),
)
# Send a few messages and receive echoes.
messages = ["Hello, OpenEnv!", "IDEGym running with OpenEnv server", "Done."]
for message in messages:
result = echo.step(EchoAction(message=message))
logger.info(
event="step",
sent=message,
echoed=result.observation.echoed_message,
length=result.observation.message_length,
reward=result.reward,
done=result.done,
)
logger.info("Example completed successfully!")
if __name__ == "__main__":
run(main())
Hi!
At JetBrains, we are developing a code execution backend (currently called IDEGym) specifically tailored for reinforcement learning. We are planning to open source it in the near future and wanted to suggest a possible integration.
Our tool is currently focused on supporting agentic coding training for a variety of complex tasks. For example, it can handle SWE-bench–style tasks where rewards are derived from executing comprehensive test suites, as well as environment setup tasks where rewards come from successfully building or analyzing a project.
We were able to adapt the OpenEnv protocol and communication approach to run OpenEnv environments on our Kubernetes cluster using our own orchestrator.
I'm attaching an example of code showing how we communicate with an OpenEnv environment using our client. Ideally, we would love to build a proper integration, but before submitting a PR we wanted to discuss some details with you. Since we are working on Kubernetes integration, some of our solutions might also be relevant for you, especially given your plans to support k8s and the discussion around the role of an orchestrator in issue #199.
Is there any active work on Kubernetes support or any existing ideas regarding the design of the provider? I have reviewed issue #199 , but did not find any additional information beyond that.
P.s.: The example is purely for demonstration of implementation since IDEGym is not open sourced yet, but I hope soon you will be able to play with it.
P.p.s: If needed, I can open RFC -- not sure if the question on the level of it or not.