Skip to main content
An environment server runs during each attempt. It serves the tools that the model can call, keeps the state of the attempt, and holds the grader. It is a NeMo Gym resources server in app.py, which monte env create writes from Gym’s template.

How an Attempt Runs

  1. The agent sends the task row to the server’s seed_session endpoint, which opens a session for the attempt.
  2. The agent sends the row’s input and tools to the model.
  3. Each time the model calls a tool, the agent sends the arguments to the server endpoint with the same name and returns the result to the model.
  4. When the model stops, the agent sends the whole answer and the row’s grader fields to verify.
The agent is Gym’s simple_agent, which allows a set number of turns in each attempt. In training, the recipe key grpo.max_turns sets that limit. Monte records the answer, the tool calls, and the reward as a trace.

Add a Tool

A tool is a FastAPI endpoint that setup_webserver adds, plus a declaration with the same name in the task rows. The support_escalation server has two tools:
The support_escalation server ranks articles with the open-weight embedding model Qwen/Qwen3-Embedding-0.6B, which runs in the server process. A tool can also call an outside API with a key from a team secret. A training environment calls open-weight models only.

Keep State for Each Attempt

Many attempts run at the same time on one server, so the server keys its state by the session ID. The same session ID reaches seed_session, each tool, and verify:
verify(self, request, body) clears the state of the attempt with self.tickets.pop(request.session[SESSION_ID_KEY], None). To start an attempt from a state that the row sets, override seed_session, which receives the whole row. A verify that scores this state, such as one that reads the categories it pops from self.tickets, cannot rescore, because the state ends with the attempt. The support_escalation grader reads the hand-off from the response, so its runs can rescore.

Server Config

configs/support_escalation.yaml names the server, sets its config fields, connects it to the agent and the model, and declares the training rows:
The fingerprint covers this file, so a changed field, such as a new top_k, needs a new monte env add.