nemo_gym.base_resources_server
nemo_gym.base_resources_server
Module Contents
Classes
Functions
Data
NEMO_GYM_MCP_SESSION_TOKEN_HEADER
API
Bases: BaseVerifyResponse
Base verify response for environments with multiple reward objectives.
Subclass this response instead of declaring reward_components on an
environment-specific BaseVerifyResponse subclass. The mapping is required, and
its objective keys should remain consistent across every task in the environment.
Set the inherited reward to the scalar aggregate expected by single-reward
consumers. To include individual objectives in aggregate metrics, also expose them
as top-level numeric fields because metrics do not descend into this mapping. See
resources_servers/example_tool_call_multireward for a complete example.
Bases: BaseServer
Bases: BaseModel
Bases: BaseModel
Bases: BaseModel
Bases: BaseRunRequest
Bases: BaseVerifyRequest
Producers learn about a name outside the vocabulary without losing the failure.
Validation warns rather than rejects: an unregistered kind is a migration signal, and dropping the response over it would replace a visible wrong label with an invisible lost failure.
Bases: BaseModel
Metadata returned from /seed_session for per-rollout Gym MCP access.
Bases: BaseModel
Close resources-server state.
Bases: BaseModel
Confirm resources-server state was closed.
Bases: BaseModel
Idempotently initialize resources state under a caller-assigned identifier.
Repeating the same identifier and episode must return the existing session. Closing an unknown identifier must prevent a racing seed from creating it later. External resources should use provider TTLs when available. Current process-local session records may remain until the server shuts down.
Bases: BaseModel
Confirm resources state and return optional agent access.
Bases: BaseModel, Generic[VerificationInputT]
Carry typed environment output to a resources server.
Bases: enum.Enum
Bases: BaseResourcesServer, AggregateMetricsMixin, SimpleServer
Compute aggregate metrics from verify responses.
RewardProfiler provides baseline stats. Override compute_metrics(), compute_repeat_metrics(), and/or get_key_metrics() for benchmark-specific customization.
Close state an Environment Server seeded; the default keeps none.
Served at /close_session. Servers that keep per-rollout state override this method, and may accept
other close bodies by overriding it with a different signature. The name differs from the
close_session helpers some servers already define for their own state.
An override must:
- succeed when the session is already closed or was never seeded;
- keep a seed that arrives after the close from creating the session again;
- raise when releasing fails rather than recording the session as closed, so the caller can retry.
The default seed does not tie the session cookie to resources_session_id. A server that keys state
by the cookie’s SESSION_ID_KEY releases it by that key, from request.session, or sets
request.session[SESSION_ID_KEY] = body.resources_session_id in its own seed.
nemo_gym.testing.session_conformance.check_resources_session_contract checks these rules from a server’s tests.
Per-session tool restriction: return the tool names allowed for this rollout’s MCP token,
or None (the default) for unrestricted. seed_body is the JSON body POSTed to
/seed_session, or its task_data when an Environment Server seeds the session.
Return the MCP tools to expose (default: the auto-harvested typed POST routes).
Override to exclude (filter harvested), add catch-all-backed tools (harvested + [catchall.tool(…)]), or disable (return None). ‘catchall’ is None unless the server has one parameterized catch-all route.
Strip this server’s MCP namespace from a trajectory tool-call name (see module function).
Seed per-rollout state; the default keeps none.
An Environment Server seeds with a ResourcesSeedSessionRequest and gets its caller-assigned
resources_session_id back. An Agent’s /run seeds with its legacy body and gets an empty
response. Servers that keep per-rollout state override this method.
Map a trajectory tool-call name to the server’s bare tool name.
HTTP-driven agents record bare tool names (“email_reply_email”); MCP-native agents (e.g.
Claude Code) record them namespaced per server (“mcp__workplace_assistant__email_reply_email”).
Verifiers compare trajectory names against dataset/ground-truth vocabulary, so names are
normalized before verify sees them and rollouts score identically on both transports.
Non-namespaced names pass through unchanged. When server_name is given, only that server’s
prefix is stripped (robust to tool names that themselves contain double underscores).
This runs only for servers exposed over MCP and mirrors how MCP clients namespace tool names,
so a real tool that is itself named mcp__<server>__x being stripped is accepted.