Repository navigation
fix: write traces on timeout (Apptainer) + improve Hermes traces - #1973
Conversation
Signed-off-by: Elisa Martinez Abad <[email protected]>
Signed-off-by: Elisa Martinez Abad <[email protected]>
Signed-off-by: Elisa Martinez Abad <[email protected]>
|
/claude review |
|
SHIP WITH CARE — two independent, additive reliability changes. No verifier/scorer/reward-aggregation logic touched; no async-HTTP or ray.get() violations; imports resolve.
RISK to flag for the author's decision: no test covers the new reasoning-item branch in Nothing here silently corrupts scores or hangs a run. Merge after deciding on the env-var parse and the missing tests. |
Signed-off-by: Elisa Martinez Abad <[email protected]>
…uts them Signed-off-by: Elisa Martinez Abad <[email protected]>
| model=model_name, | ||
| object="response", | ||
| output=output_items, | ||
| status="completed" if agent_completed else "incomplete", |
There was a problem hiding this comment.
Harness/API failures have completed=False, so this labels them incomplete even when error is populated and metadata.failed=true. Should this return failed when harness_error or result["failed"] is set?
There was a problem hiding this comment.
Changed the logic to achieve this.
Previously only agent_completed drove status, so a harness_error or result["failed"] with completed=False still reported status="incomplete", indistinguishable from the model running out of turns. Signed-off-by: Riccardo Roveri <[email protected]>
|
/ok to test 3a4948f |
|
/ok to test 5b5240e |
# Fix Hermes agent traces and sandbox timeout handling ## Summary Ensures Hermes agent trajectories are captured and surfaced even when a run times out or fails, and makes the Apptainer sandbox timeout terminate processes gracefully so in-container agents can flush partial traces before being killed. ## Changes ### `nemo_gym/sandbox/providers/apptainer/provider.py` - On timeout, send `SIGTERM` to the process group first and wait a short grace period (default 15s, configurable via `NEMO_GYM_SANDBOX_TIMEOUT_GRACE_S`), then `SIGKILL` only if the process is still alive. This gives an in-container agent's SIGTERM handler a chance to flush a partial trace before it's hard-killed. Applied to both timeout paths. ### `responses_api_agents/hermes_agent/app.py` - **Reasoning in traces:** emit assistant `reasoning` text as a `NeMoGymResponseReasoningItem` in the output items. - **Incomplete detection:** mark the response `status="incomplete"` when `run_conversation` reports it didn't complete (ran out of turns / blew the context window). - **Interruption tracking:** track interrupted agents (`interrupted_agents` set) via the SIGTERM dispatcher so timeouts are reflected in the response. - **Diagnosability metadata:** populate response `metadata` with `interrupted`, `failed`, `partial`, `turns`, and `hermes_error`, and set the structured `error` field (`code="server_error"`, message from the harness error) when the run fails. ## Motivation Timeouts and failures previously produced empty or misleading traces (a hard kill left no trace; incomplete runs could score as passes). These changes preserve partial trajectories and expose run outcome, making failed and timed-out rollouts diagnosable. ## Env vars - `NEMO_GYM_SANDBOX_TIMEOUT_GRACE_S` (default `15`) — grace period between SIGTERM and SIGKILL on sandbox timeout. --------- Signed-off-by: Elisa Martinez Abad <[email protected]> Signed-off-by: Riccardo Roveri <[email protected]> Co-authored-by: Christian Munley <[email protected]> Co-authored-by: Riccardo Roveri <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
Fix Hermes agent traces and sandbox timeout handling
Summary
Ensures Hermes agent trajectories are captured and surfaced even when a run times out or fails, and makes the Apptainer sandbox timeout terminate processes gracefully so in-container agents can flush partial traces before being killed.
Changes
nemo_gym/sandbox/providers/apptainer/provider.pySIGTERMto the process group first and wait a short grace period (default 15s, configurable viaNEMO_GYM_SANDBOX_TIMEOUT_GRACE_S), thenSIGKILLonly if the process is still alive. This gives an in-container agent's SIGTERM handler a chance to flush a partial trace before it's hard-killed. Applied to both timeout paths.responses_api_agents/hermes_agent/app.pyreasoningtext as aNeMoGymResponseReasoningItemin the output items.status="incomplete"whenrun_conversationreports it didn't complete (ran out of turns / blew the context window).interrupted_agentsset) via the SIGTERM dispatcher so timeouts are reflected in the response.metadatawithinterrupted,failed,partial,turns, andhermes_error, and set the structurederrorfield (code="server_error", message from the harness error) when the run fails.Motivation
Timeouts and failures previously produced empty or misleading traces (a hard kill left no trace; incomplete runs could score as passes). These changes preserve partial trajectories and expose run outcome, making failed and timed-out rollouts diagnosable.
Env vars
NEMO_GYM_SANDBOX_TIMEOUT_GRACE_S(default15) — grace period between SIGTERM and SIGKILL on sandbox timeout.