app.py, which monte env create writes from Gym’s template.
How an Attempt Runs
- The agent sends the task row to the server’s
seed_sessionendpoint, which opens a session for the attempt. - The agent sends the row’s
inputandtoolsto the model. - 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.
- When the model stops, the agent sends the whole answer and the row’s grader fields to
verify.
simple_agent, which allows a set number of tool calls in each attempt. Monte records the answer, the tool calls, and the reward as a trace.
Add a Tool
A tool is a FastAPI endpoint thatsetup_webserver adds, plus a declaration with the same name in the task rows. The support_escalation server has two tools:
support_escalation server embeds each search_kb query with an OpenAI model, so it reads OPENAI_API_KEY from a team secret.
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 reachesseed_session, each tool, and verify:
verify(self, request, body) reads self.tickets[request.session[SESSION_ID_KEY]]. To start an attempt from a state that the row sets, override seed_session, which receives the whole row. A grader that reads this state cannot regrade, because the state ends with the attempt.
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:
top_k, needs a new monte env add.
