Skip to content

fix(stirrup_agent): grade unusable compaction summaries as the model's output - #5822

Merged
AdamRajfer merged 1 commit into
mainfrom
arajfer/stirrup-compaction-typing
Nov 8, 2026
Merged

AdamRajfer merged 1 commit into
mainfrom
arajfer/stirrup-compaction-typing

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

Problem

When the policy model returns no usable compaction summary on all three attempts, the stirrup agent raised a bare RuntimeError. The sandbox runner reported it as a runner failure, the agent route returned HTTP 500, and the environment server typed the episode environment_server_failed and retried it. The summary comes from the policy model, so a retry only re-samples the same model; it is not an infrastructure fault.

Change

  • nemo_agent.py: raise CompactionSummaryError (a RuntimeError subclass) carrying the context it was asked to summarize.
  • sandbox_runner.py: end the episode as a failed response that keeps every completed turn (stop_reason compaction_failed), as the 4xx model error path already does.
  • app.py: classify that response as agent_invalid_output, which the default outcome policy verifies instead of retrying, as for other unusable model output.

Tests

The new and changed tests fail before the change and pass after it (96 of 96 in the three touched test files). Ruff is clean.

…s output

When the policy model returned no usable compaction summary on all three
attempts, the agent raised a bare RuntimeError, the sandbox runner reported
it as a runner failure and the environment server typed the episode
environment_server_failed and retried it. The summary comes from the policy
model, so a retry only re-samples the same model and the row is not an
infrastructure fault.

The agent now raises CompactionSummaryError with the context it was asked
to summarize. The runner ends the episode as a failed response on every
completed turn (stop_reason compaction_failed), and the agent classifies it
as agent_invalid_output, which the default outcome policy verifies instead
of retrying, as for other unusable model output.

Signed-off-by: Adam Rajfer <[email protected]>

@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

RISK — Add the required real-model smoke evidence

The supplied PR description reports 96 unit tests and Ruff, but no representative real-model rollout or justified N/A. AGENTS.md requires real smoke rollouts for behavior-changing agent work. This change affects evaluation outcomes: the new classification sends previously retryable episodes to verification under the default policy. The added runner test injects the exception, and the wrapper test supplies a synthetic report; neither demonstrates the full model-to-verifier path. This is a validation gap, not a demonstrated runtime defect.

Correction: Could you add the model, task, configuration, commands, saved rollout artifact, and inspected agent/verifier result to the PR evidence? No implementation rewrite is requested. The invariant to demonstrate is that unusable policy summaries end and grade the current episode while retaining its completed work, rather than restarting it as an infrastructure failure.

Proposed acceptance checks:

  • Run a real policy model on a task that reaches compaction, with a minimum-summary setting that rejects all three summaries. Confirm retained completed tool calls/results and task artifacts, response status failed, stop reason compaction_failed, outcome agent_invalid_output, and verifier execution without an agent-outcome retry under the default policy.
  • Retain a successful-compaction control that continues normally and replays only the sanitized summary, as asserted by the existing session compaction test.
  • Preserve the existing rejected-request assertions: HTTP 400/413/422 remains model_request_error, with known-zero usage when no model response was received.

I inspected all seven changed files and traced exception handling, history conversion, report transport, outcome policy, and environment verification. I found no additional source-supported defects. Inspection was static: I couldn't execute tests or rollouts, and the external Stirrup implementation wasn't mounted for independent inspection.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior needs-review PR is ready for code review and waiting on a reviewer labels Nov 8, 2026
@AdamRajfer
AdamRajfer requested a review from agronskiy November 8, 2026 18:58

@agronskiy agronskiy 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.

Looks good, approving with a few nits.

Verified: the only NeMoAgent construction site is sandbox_runner.run, so the new except CompactionSummaryError covers the path that previously surfaced as an unclassified HTTP 500 from /run. Replacing the last turn snapshot with error.messages correctly retains the turn that triggered compaction, since Stirrup snapshots at turn start and compacts after the turn is appended. agent_invalid_output maps to VERIFY under the default policy, and 400/413/422 still classify as model_request_error. Stirrup tests pass (178), the two new tests fail without the fix, and ruff is clean.

Nits:

  1. nemo_agent.py: CompactionSummaryError carries current_messages, which has already dropped a turn if a summary attempt hit ContextOverflowError and unwound. The failed response then omits a turn that model_response_ids and usage still count. Passing the original messages would keep every completed turn, as the README now says.
  2. app.py: response.error is None and the invalid_output text isn't kept anywhere on the response. Consider adding it to metadata for diagnosis.
  3. app.py comment: "never retried" depends on the outcome policy. Maybe "verified by default".

FYI for GDPVal users: these rollouts used to be rerun by recovery (HTTP 500 agent_run_error) and are now graded as the model's result, so scores on runs with compaction failures will shift. A note in the PR description would help.

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

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit 72275b8 Nov 8, 2026
65 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/stirrup-compaction-typing branch November 8, 2026 20:46
osoblanco added a commit to osoblanco/Gym that referenced this pull request Nov 15, 2026
Merge main at 330c461 into the agentic CritPt branch. Where main has
since added its own handling for something this branch also changed,
the merge keeps main's version:

- responses_api_models/vllm_model is identical to main. The exact
  completion fitting is dropped; main's refit_output_budget_to_prompt
  (NVIDIA-NeMo#5864) covers what the agentic recipe needs.
- Stirrup compaction failure uses main's handling (NVIDIA-NeMo#5822) and its
  max_turns stop reason (NVIDIA-NeMo#5937). In finish_tool mode the grader scores
  an agent_invalid_output response zero as candidate_no_answer.
- Context-overflow recovery becomes the opt-in Stirrup option
  context_overflow_recovery (default false). The runner reports the
  model server's own rejection.
- The grader's execution sessions use ResourcesSessionLocks and
  ResourcesSessionFences (NVIDIA-NeMo#5083); agentic_execution refuses several
  workers (NVIDIA-NeMo#4790).
- A semantic validator failure or timeout stays unscorable with
  score_comparator_uncertain_as_incorrect (NVIDIA-NeMo#5416).
- nemo_gym/ is unchanged.

Two fixes found while validating the merge:

- Since NVIDIA-NeMo#5128 the single_agent_turn environment servers and the agents
  that verify through verify_agent_response send failure_report with
  every /verify request. The grader read it as an unknown task field
  and answered task_invalid for every such rollout; it is now a
  framework field.
- tests/test_runner_remote.py built ExecutionPolicy with four arguments
  the policy does not have and expected a 2 GiB address-space limit it
  never set, so nine of its tests failed; both are corrected.

Also included: fixes from a review of the merged diff (session glossary
wording, main's lost-session body on /code_exec, tighter execution
limits, a stopped session releasing its capacity slot, route tests, and
a local end-to-end grade of a semantic-validator task).

Signed-off-by: Erik Arakelyan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

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

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants