Skip to navigation

nemo_gym.agents.utils.verify_call

View as Markdown

An agent’s verify call, with a bounded retry of a verify call lost in transport.

A verify call whose reply was lost (the body cut off mid-read, the peer dropped the connection, a timeout) has no verdict, and an agent that masks its row then keeps a completed answer ungraded. The call is tried again, up to VERIFY_CALL_MAX_ATTEMPTS attempts with the judge call’s full-jitter backoff, before the failure reaches the agent. A verify request that may have been delivered is sent again only to a verifier that reports itself STATELESS (GET /reverify_mode): grading the same saved answer again is then safe. An HTTP reply (any status) is the verifier’s own answer and is never retried here.

Module Contents

Functions

NameDescription
_retry_wait_sFull-jitter exponential backoff after failed attempt attempt (1-based), as a judge call waits.
_stateless_verifierWhether the verifier reports STATELESS; a verifier that cannot say is not resent a delivered request.
is_verify_transport_errorWhether a failed verify call lost its reply in transport, so another attempt can succeed.
masked_verify_failureanswer (the verify request, with the generated response) as a masked zero for a verify call that failed.
verify_route_failureThe agent boundary’s failure of one verify attempt, caused by error; agent_route_failure for verify with
verify_with_transport_retryAwait call (one verify request and its parsed reply), retrying a reply lost in transport.

Data

VERIFY_CALL_MAX_ATTEMPTS

_TRANSPORT_ERRORS

API

nemo_gym.agents.utils.verify_call._retry_wait_s(
attempt: int
) -> float

Full-jitter exponential backoff after failed attempt attempt (1-based), as a judge call waits.

nemo_gym.agents.utils.verify_call._stateless_verifier(
server_name: str
) -> bool
async

Whether the verifier reports STATELESS; a verifier that cannot say is not resent a delivered request.

nemo_gym.agents.utils.verify_call.is_verify_transport_error(
error: BaseException
) -> bool

Whether a failed verify call lost its reply in transport, so another attempt can succeed.

nemo_gym.agents.utils.verify_call.masked_verify_failure(
answer: dict[str, typing.Any],
regradable: bool = True
) -> dict[str, typing.Any]

answer (the verify request, with the generated response) as a masked zero for a verify call that failed.

Return this from /run instead of raising: the HTTP boundary would drop the generated answer, and a resume would generate again. The typed failure is the one verify_with_transport_retry raised.

A verifier that replied with a server error or a rate limit could not grade the answer: the row is a judge_failed mask, which recovery grades again from the saved answer with /verify only. A call lost in transport keeps its agent_route_failed kind, which recovery selects too. A verifier that cannot grade one saved answer alone (regradable=False, a verifier that grades only full batches) keeps agent_route_failed for every cause, so recovery does not claim it can settle the row.

nemo_gym.agents.utils.verify_call.verify_route_failure(
error: BaseException,
operation_id: str,
attempt: int

The agent boundary’s failure of one verify attempt, caused by error; agent_route_failure for verify with the attempt named, so a retried call keeps every attempt as an observation.

nemo_gym.agents.utils.verify_call.verify_with_transport_retry(
call: collections.abc.Callable[[], collections.abc.Awaitable[typing.Any]],
server_name: str
) -> typing.Any
async

Await call (one verify request and its parsed reply), retrying a reply lost in transport.

Every failed attempt is observed as its own agent_route_failed event of operation verify (one operation_id per call, the attempt in attempt_id). A transport failure is tried again, up to VERIFY_CALL_MAX_ATTEMPTS attempts, only against a STATELESS verifier. The last failure is raised as that event, from its cause; any other failure is raised the same way at once.

nemo_gym.agents.utils.verify_call.VERIFY_CALL_MAX_ATTEMPTS = JUDGE_CALL_MAX_ATTEMPTS

Attempts of one verify call (the first one included) before its transport failure reaches the agent.

nemo_gym.agents.utils.verify_call._TRANSPORT_ERRORS = (ClientPayloadError, ClientConnectionError, ConnectionError, TimeoutError)