Skip to content

fix(model): preserve upstream execution outcomes - #3761

Merged
Glorf merged 4 commits into
mainfrom
mbien/fep-1477-execution-outcomes
Sep 30, 2026
Merged

Glorf merged 4 commits into
mainfrom
mbien/fep-1477-execution-outcomes

Conversation

@Glorf

@Glorf Glorf commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Preserve execution facts when vLLM returns a local empty response or adapts an upstream context-overflow rejection into HTTP 200. Four optional fields record the upstream attempt, response source, upstream status, and local reason through capture, ModelCallRecord, and trajectory metadata. Adapted overflow records context_length_exceeded.

Closes #2792 / FEP-1477.

Four production files: 64 additions, 2 deletions. No test or documentation changes.

Validation

python -m pytest responses_api_models/vllm_model/tests/test_app.py tests/unit_tests/test_base_responses_api_model.py tests/unit_tests/test_rollout_observability.py tests/unit_tests/test_rollout_collection.py responses_api_agents/harbor_agent/custom_agents/llms/test_nemo_gym_llm.py -q --tb=short --durations=5 -o log_cli=false
# 518 passed
python -m pre_commit run --all-files
git diff --check
# Passed

The unchanged production implementation also passed execution-metadata regression checks before those test additions were removed. No new regression tests are retained in this PR; the issue's request for durable automated coverage remains outstanding.

Rollouts

Model-route checks used mocked upstream responses. No live-model rollout or full CI suite was run locally. This remains a draft for author review.

Compatibility and benchmark impact

Response bodies, statuses, IDs, finish reasons, retries, and Harbor behavior remain unchanged. No new HTTP header. Existing records treat absent metadata as unknown. Successful upstream status remains unknown where the client only returns decoded JSON.

Harbor migration is deferred as permitted by the issue; its existing empty-assistant misclassification remains. Observability error counts now include adapted overflow; rewards are unchanged.

@Glorf Glorf added bug Something isn't working area:model Model servers, inference providers, and model adapters labels Sep 29, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Glorf
Glorf marked this pull request as ready for review September 29, 2026 12:40
@giuliolovisotto

Copy link
Copy Markdown
Contributor

/claude review

@giuliolovisotto
giuliolovisotto self-requested a review September 29, 2026 13:24
@claude

claude Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — mostly additive telemetry plumbing; one behavior change to double-check.

This adds upstream_attempted / response_source / upstream_status_code / local_response_reason to the model-call record, threads a ModelExecutionOutcome from the vLLM adapter through request.state into _CaptureMiddleware, and projects the fields into trajectory metadata. The wiring is clean: Literal/TypedDict imports are present, Literal is imported in rollout_observability.py, the scope.setdefault("state", {}) sharing with Request.state is sound (Starlette backs Request.state with scope["state"]), and _record stays best-effort.

One finding worth a look (inline): stamping error_category="context_length_exceeded" in _record reclassifies locally-served context-overflow fallbacks (HTTP 200, the default propagate_context_overflow_errors=false path) as failed model calls via health/checks.py::_is_failed. That's a semantic change from prior behavior where those calls were successful. If it's intentional, note it in the PR body and confirm nothing downstream gates on those findings; if the goal is purely observability, local_response_reason already carries the signal without flipping the failed/successful accounting.

Everything else is low-risk. No async/API-compat concerns.

if execution is not None:
exchange.update(execution)
if execution["local_response_reason"] == "context_length_exceeded":
exchange["error_category"] = "context_length_exceeded"

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.

RISK — Local context-overflow fallbacks are now classified as failed model calls.

What breaks: When propagate_context_overflow_errors is false (the default), vLLM's chat/completion paths swallow the upstream 400 and return a local empty completion (finish_reason="length", HTTP 200). Previously this exchange had error_category=None and _classify_status(200)=None, so health/checks.py::_is_failed treated it as a successful call. This line now stamps error_category="context_length_exceeded" on it, so _is_failed (checks.py:285, bool(call.get("error_category"))) returns True and _model_call_failed (checks.py:591) emits a model_call_failed finding for every context-truncated call.

Blast radius: Any existing run that relied on graceful local context-overflow truncation will start reporting those calls as failed in health reports / _is_successful accounting. The empty_assistant local reason is (correctly) left untouched, so this is specific to context overflow — but it silently reclassifies a previously-clean, expected outcome across all vLLM callers.

Fix: If the intent is purely observability, keep the distinction in local_response_reason/response_source (which is additive and harmless) and drop the error_category promotion; or, if flagging is intentional, confirm the health-check / metrics impact is desired and note it in the PR description. Worth verifying nothing downstream gates rollout acceptance on these findings.

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.

This is a problem in the health check implementation. For me this PR can be merged, I'll address this problem separately.

@Glorf
Glorf force-pushed the mbien/fep-1477-execution-outcomes branch from 984e710 to 25a5da4 Compare September 29, 2026 15:32
@Glorf

Glorf commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 25a5da4

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team September 29, 2026 15:34
giuliolovisotto added a commit that referenced this pull request Sep 29, 2026
Recovered context-overflow rejections must not fail generation checks.
Restrict failed-call findings to the final owned call of a finished root
invocation; retain earlier and subagent failures in diagnostics.

Emit model_call_last_failed; accept model_call_failed in ignore settings.

Refs #3761

Signed-off-by: Giulio Lovisotto <[email protected]>
@yaoyu-33 yaoyu-33 added complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer labels Sep 29, 2026
@Glorf

Glorf commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 627d523

giuliolovisotto added a commit that referenced this pull request Sep 30, 2026
Recovered context-overflow rejections must not fail generation checks.
Restrict failed-call findings to the final owned call of a finished root
invocation; retain earlier and subagent failures in diagnostics.

Emit model_call_last_failed; accept model_call_failed in ignore settings.

Refs #3761

Signed-off-by: Giulio Lovisotto <[email protected]>
@Glorf
Glorf added this pull request to the merge queue Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit 35454e7 Sep 30, 2026
44 checks passed
@Glorf
Glorf deleted the mbien/fep-1477-execution-outcomes branch September 30, 2026 12:30
giuliolovisotto added a commit that referenced this pull request Oct 1, 2026
Recovered context-overflow rejections must not fail generation checks.
Restrict failed-call findings to the final owned call of a finished root
invocation; retain earlier and subagent failures in diagnostics.

Emit model_call_last_failed; accept model_call_failed in ignore settings.

Refs #3761

Signed-off-by: Giulio Lovisotto <[email protected]>
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 5, 2026
A model call that fails and is then retried successfully can still make
a rollout unhealthy because `model_call_failed` flags every bound
failure. Remove that check and use `rollout_ended_on_failed_model_call`
from NVIDIA-NeMo#3427 unchanged. Earlier failures remain in diagnostic counts.
Existing ignore settings using `model_call_failed` map to the retained
check.

Keep the explicit context-overflow exemptions from this follow-up to
NVIDIA-NeMo#3761: rejected requests do not trigger missing-token,
zero-completion-token, or runaway-generation findings. The vLLM adapter
records the rejection category with propagation enabled or disabled;
HTTP behavior is unchanged. A final rejection still counts as a failure
under the retained check. Its existing per-model semantics apply,
including to subagent and auxiliary calls.

No separate issue is needed for this focused follow-up. Rewards and
benchmark scores are unchanged.

Validation:

- `python -m pytest tests/unit_tests/test_rollout_health.py
responses_api_agents/opencode_agent/tests/test_trajectory.py
tests/unit_tests/test_fern_docs_links.py --no-cov -q`: 173 passed, 17
subtests passed.
- `python -m pytest responses_api_models/vllm_model/tests/test_app.py -k
context_overflow_propagation_flag --no-cov -q`: 4 passed.
- `python -m pre_commit run --all-files`: passed.
- `cd fern && npm run check`: passed (0 errors, 1 warning).
- MiniSWE/Terminus observability tests are delegated to full server CI;
the combined local harness test command could not collect because
`minisweagent` is not installed in the core environment.
- [GitHub
CI](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37276179587) on
rebased head `0dbbd3772`: passed, including the core coverage gate and
all eight server shards. No unresolved CodeRabbit review threads.

Live-model rollout: N/A. Changes are limited to postprocessing and
captured error metadata; inference and agent execution behavior are
unchanged.

Signed-off-by: Giulio Lovisotto <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 627d5235 Deployed Sep 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #4025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model servers, inference providers, and model adapters bug Something isn't working complexity:medium Single-domain change with interacting parts or a moderate review surface 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.

Preserve upstream execution outcomes in model-call observability

3 participants