Skip to content

feat(timeouts): typed deadline evidence at RemoteAgent limits and the collector /run deadline - #5603

Merged
AdamRajfer merged 3 commits into
mainfrom
arajfer/deadline-evidence-on-3879
Nov 5, 2026
Merged

AdamRajfer merged 3 commits into
mainfrom
arajfer/deadline-evidence-on-3879

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • RemoteAgent's per-request limit (remote_responses_timeout_secs) and whole-run limit (run_timeout_secs) produce a remote_agent_error row 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 TimeoutEvent on the row (limit, enforcer, configured time, and elapsed time where it is known), tied by event id to a failure event.

  • RemoteAgent observes a remote_agent:request_deadline or remote_agent:run_deadline failure. It names the active operation (seed_session, agent or verify) 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 as RemoteAgentDeadlineError, 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 plain RemoteAgentError. 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.
  • Collection records no deadline evidence: it sets no deadline of its own on /run (the shared client is unbounded), so a TimeoutError there comes from a connect sub-limit or elsewhere on the dispatch path and is not attributed to a limit.
  • Elapsed time: the whole-run deadline records its measured 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

  • The failures are observed, not selected, and their kinds are namespaced, so routing, retries and scores are unchanged.
  • timeouts is 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_mgmt resources server, 3 rows per run, and a local /v1/responses service 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:

    Run Settings Result
    Control defaults, no delay 3/3 completed, reward 1.0, no failure or timeout evidence
    Request deadline remote_responses_timeout_secs: 5, 20 s delay 3/3 failed with one remote_responses_timeout_secs event each, failure kind remote_agent:request_deadline
    Run deadline remote_responses_timeout_secs: 60, run_timeout_secs: 5, 20 s delay 3/3 failed with one run_timeout_secs event each (elapsed 5.00-5.05 s), failure kind remote_agent:run_deadline

    In both deadline runs each timeouts[].event_id equals the id of its failure event (boundary agent, operation remote_agent.agent). The rows stay the retryable remote_agent_error sentinel with no terminal flag, so a resume retries all 3. The row-level failure_kind stays 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_s from the request deadline.

🤖 Generated with Claude Code

@AdamRajfer AdamRajfer self-assigned this Nov 4, 2026
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test ed77036

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py line 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, and classify_timeout misses 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 e
    

    This restores the invariant that the request deadline remains recognizable across the self-post regardless of whether headers arrived. Keep ClientPayloadError and 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_failure so the timeout case asserts one remote_responses_timeout_secs event, typed timeout classification, an observed failure with the same event ID, reward zero, no terminal flag, and no verification call. Its ClientPayloadError case 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.

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 8423ada

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 5889f96

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 67e03b6

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

@marcromeyn marcromeyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. collection.run is inferred from the exception type, not from the deadline that fired (rollout_collection.py:5349). isinstance(e, TimeoutError) and status is None also matches aiohttp's ConnectionTimeoutError (a connect sub-limit, which is a TimeoutError) and any asyncio.timeout elsewhere on the dispatch path; both produce a collection.run event in a quick probe. The other way round, a timeout while reading the body after 200 headers gets no event, because res.status is set. Since the timeout reader counts these, a wrong attribution shows up as a deadline that wasn't hit. Which deadline is collection.run meant to be? The shared client is created with an unbounded ClientTimeout() (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 bare TimeoutError? The current test also doesn't assert the event-id join.
  2. The per-request deadline's elapsed_s measures the whole agent loop (remote_agent/app.py:498). loop_started is 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_responses time the attempt that expired (including the body read) and carry that across the self-post, leaving elapsed_s out if it can't be recovered? A multi-turn test comparing it with the failing request's duration would pin it; the current one checks elapsed_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.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks @AdamRajfer—could you address Marc’s two deadline-evidence requests and small docs suggestion? I independently reproduced both deadline-evidence issues on 59e02abe.

One additional nonblocking cleanup: please export TimeoutEvent and classify_timeout through nemo_gym.rollouts and use those public imports in RemoteAgent and its tests, as required by AGENTS.md.

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]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 6fe4060

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

Thanks Marc, both were right. Fixed in 6fe4060:

  1. There is no collection deadline behind collection.run: the shared client is unbounded and nothing wraps the /run post, so any TimeoutError there comes from somewhere else. I dropped that evidence instead of guessing; the test now pins that a bare timeout, a connect timeout, a status and a refused connection leave none.
  2. The request deadline no longer reports elapsed_s. The expired request's own duration doesn't cross the self-post, and the loop's overstates it, so it's left out. The run deadline keeps its measured one.

Also added timeouts to the stripped-fields line in the remote agent docs, and updated the description.

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42097278261

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

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.

@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42105452706

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42123379905

Merged via the queue into main with commit 06fac5f Nov 5, 2026
65 of 68 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/deadline-evidence-on-3879 branch November 5, 2026 22:55

This branch was previously deployed

1 inactive deployment
public — 6fe40604 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants