Repository navigation
feat(timeouts): typed deadline evidence at RemoteAgent limits and the collector /run deadline - #5603
Conversation
|
/ok to test ed77036 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found two RISK items: the inline finding covers an unreported body-read deadline, and the validation evidence gap is below. I inspected all five changed files and the affected transport, failure-export, persistence, recovery, and timeout-reader paths. This was a static review; I didn't execute tests.
RISK — Provide representative real smoke-rollout evidence
The supplied validation reports unit suites, but no representative real model rollout or justified N/A. AGENTS.md requires real smoke rollouts for behavior-changing agent work. The new deadline observation path depends on request-scoped failure export, while the added tests replace observe_failure with a list append. They don't establish that the observations reach saved rollout rows. This is missing required evidence, not a demonstrated export defect.
Could you provide the commands, effective configuration, and inspected artifacts from a representative RemoteAgent run with a real model and resources server, including a healthy control and an intentionally shortened run_timeout_secs? The healthy control should preserve its tool trajectory, session state, and verifier reward without timeout evidence. The deadline case should retain the retryable remote_agent_error sentinel and no-generation placeholder, omit the terminal flag, and save one run_timeout_secs event whose ID resolves to an observed failure with the active operation/stage. Confirm that classify_timeout recognizes the saved row without changing retry or score handling. Retain the queue-wait exclusion and semaphore-release assertions in TestRunTimeoutAndSemaphore. No implementation patch is warranted for this evidence gap.
Inline comments (escaped v1):
-
responses_api_agents/remote_agent/app.pyline 371: RISK — Preserve deadline classification when the response body times out.When the remote service returns headers and then its body read times out, this branch still raises
RemoteAgentError. The new exact-class check therefore supplies no deadline, andclassify_timeoutmisses the rollout. The existing body-read test already gives a minimal reproduction:FakeRemoteResponse(200, b"", read_exc=asyncio.TimeoutError()). This leaves the new per-request reporting incomplete: expiration while waiting for headers is recognized, but expiration while reading the same request's body isn't.At this raise in
_post_agent_responses, select the deadline subclass only for a timeout, preserving the existing error text and cause:error_class = RemoteAgentDeadlineError if isinstance(e, asyncio.TimeoutError) else RemoteAgentError raise error_class(f"reading the response body failed: {type(e).__name__}: {e}") from eThis restores the invariant that the request deadline remains recognizable across the self-post regardless of whether headers arrived. Keep
ClientPayloadErrorand other non-timeout read failures generic, fully received HTTP error statuses without deadline evidence, and invalid Responses objects terminal.Proposed acceptance checks, not executed: extend
test_body_read_failureso the timeout case asserts oneremote_responses_timeout_secsevent, typed timeout classification, an observed failure with the same event ID, reward zero, no terminal flag, and no verification call. ItsClientPayloadErrorcase should retain the body-read error text but have no timeout event or classification. Retain the pre-header timeout's no-retry behavior, the received-HTTP-500 case's absence of deadline evidence, invalid-trajectory terminality, and the assertions that merely mentioning an error class doesn't select it. Verify the suggested code before adopting it.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
/ok to test 8423ada |
|
/ok to test 5889f96 |
|
/ok to test 67e03b6 |
d5f3c67 to
59e02ab
Compare
marcromeyn
left a comment
There was a problem hiding this comment.
Thanks Adam, this is a good shape for the deadline evidence: the typed TimeoutEvent tied by event id to an observed failure, namespaced kinds so routing, retries and scores don't move, exact class-name recovery instead of the substring match, and the live smoke covers both RemoteAgent limits. Two things on the evidence itself before I approve:
collection.runis inferred from the exception type, not from the deadline that fired (rollout_collection.py:5349).isinstance(e, TimeoutError) and status is Nonealso matches aiohttp'sConnectionTimeoutError(a connect sub-limit, which is aTimeoutError) and anyasyncio.timeoutelsewhere on the dispatch path; both produce acollection.runevent in a quick probe. The other way round, a timeout while reading the body after 200 headers gets no event, becauseres.statusis set. Since the timeout reader counts these, a wrong attribution shows up as a deadline that wasn't hit. Which deadline iscollection.runmeant to be? The shared client is created with an unboundedClientTimeout()(http_client.py:240), so if it's a per-request total, could the code that sets it mark the expiry (or check the error is that total timeout) and the test drive a real expiry rather than injecting a bareTimeoutError? The current test also doesn't assert the event-id join.- The per-request deadline's
elapsed_smeasures the whole agent loop (remote_agent/app.py:498).loop_startedis taken before the self-post that runs every model and tool turn, so a timeout on a later request also counts the earlier turns, tool time and connect retries: a two-turn probe recorded 0.2 s against a 0.1 s limit for a request that ran 0.1 s. Could_post_agent_responsestime the attempt that expired (including the body read) and carry that across the self-post, leavingelapsed_sout if it can't be recovered? A multi-turn test comparing it with the failing request's duration would pin it; the current one checkselapsed_s >= 0.
Smaller: timeouts becoming a reserved input key is fine as you describe (a verifier's fresh timeouts still survive); worth one line in the docs for harness authors.
Happy to look again once 1 and 2 are settled.
|
Thanks @AdamRajfer—could you address Marc’s two deadline-evidence requests and small docs suggestion? I independently reproduced both deadline-evidence issues on One additional nonblocking cleanup: please export |
Collection sets no deadline of its own on /run: the shared client is unbounded, so a TimeoutError there comes from a connect sub-limit or a timeout elsewhere on the dispatch path. Drop the collection.run deadline evidence, which attributed those to a limit that does not exist, and pin that no transport failure carries it. The per-request deadline's elapsed time was measured from the start of the whole agent loop, so a timeout on a later request also counted the earlier turns. That request's own duration does not cross the self-post, so leave elapsed_s out of it; the whole-run deadline keeps its measured elapsed_s. Document that `timeouts` is stripped from reused input rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
|
/ok to test 6fe4060 |
|
Thanks Marc, both were right. Fixed in 6fe4060:
Also added |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Thanks Adam, verified 6fe406045: both deadline-evidence issues and the timeouts docs note are addressed.
Nonblocking: please export TimeoutEvent and classify_timeout from nemo_gym.rollouts and use those public imports in RemoteAgent and its tests, following AGENTS.md. This cleanup does not hold up approval.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42097278261 |
|
The body-read timeout is already handled in 59e02ab: a timeout while reading the response body now raises the deadline error like one before the headers, and a payload error stays generic. The live RemoteAgent smoke in the description covers the header-wait deadline; the body-read deadline is covered by unit tests, as noted there. |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42105452706 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42123379905 |
Replaces #5512, which carried the same change on top of other unmerged work; this PR holds only the deadline evidence, on the judge-recovery branch (#3879). #5512 had no review threads. It answers the two timeout-reporting items from this #5072 review, accepted in this reply: typed timeout evidence for the deadlines that today end a rollout with text only.
Problem
Three deadlines end a rollout without evidence the timeout reader (
classify_timeout) recognises:remote_responses_timeout_secs) and whole-run limit (run_timeout_secs) produce aremote_agent_errorrow whose only trace is the error text. The whole-run message does not say what the run was doing when it was cut.Change
Each RemoteAgent deadline now writes a
TimeoutEventon the row (limit, enforcer, configured time, and elapsed time where it is known), tied by event id to a failure event.remote_agent:request_deadlineorremote_agent:run_deadlinefailure. It names the active operation (seed_session,agentorverify) as its operation and stage, and keeps the error that ended the step as its cause. The error messages are unchanged. The per-request deadline crosses the agent's self-post asRemoteAgentDeadlineError, the way the terminal error class already does, whether it expires before the response headers arrive or while the body is read; any other body-read failure stays a plainRemoteAgentError. Both names are now recovered exactly from the serialized error, not by a substring search, so a message that merely mentions one of them is not misread./run(the shared client is unbounded), so aTimeoutErrorthere comes from a connect sub-limit or elsewhere on the dispatch path and is not attributed to a limit.elapsed_s. The per-request deadline leaves it out, because the expired request's own duration does not cross the agent's self-post and the loop's would also count earlier turns.A healthy run, an HTTP error status and a refused connection carry no deadline evidence.
Compatibility
timeoutsis now a reserved result key in RemoteAgent.Tests
RemoteAgent: per-request and whole-run deadlines in each operation, a per-request deadline during the body read, the event-id tie, the reserved key, the no-evidence cases (including a mid-body disconnect), and a message that only mentions an error name.
Collection: a bare timeout, a connect timeout, an HTTP status and a refused connection carry no deadline evidence.
The remote agent and rollout collection suites pass on this base; the full unit suite has the same failure set as the base branch.
Live RemoteAgent smoke on ed77036 (the commit before the body-read fix), no GPU: the quickstart
example_session_state_mgmtresources server, 3 rows per run, and a local/v1/responsesservice backed by an API-served Llama 3.3 70B Instruct that sleeps a set delay before it answers. The three runs differ only in their timeout settings:remote_responses_timeout_secs: 5, 20 s delayremote_responses_timeout_secsevent each, failure kindremote_agent:request_deadlineremote_responses_timeout_secs: 60,run_timeout_secs: 5, 20 s delayrun_timeout_secsevent each (elapsed 5.00-5.05 s), failure kindremote_agent:run_deadlineIn both deadline runs each
timeouts[].event_idequals the id of its failure event (boundaryagent, operationremote_agent.agent). The rows stay the retryableremote_agent_errorsentinel with no terminal flag, so a resume retries all 3. The row-levelfailure_kindstays null, as the failures are observed, not selected.Not exercised live: the body-read deadline (the service stalls before sending headers); unit tests cover it. The live runs predate dropping
elapsed_sfrom the request deadline.🤖 Generated with Claude Code