Skip to content

fix(agent): stop trajectories on incomplete reasoning - #3536

Merged
bxyu-nvidia merged 6 commits into
mainfrom
codex/stop-reasoning-only-turns
Sep 18, 2026
Merged

bxyu-nvidia merged 6 commits into
mainfrom
codex/stop-reasoning-only-turns

Conversation

@Kipok

@Kipok Kipok commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Stop SimpleAgent and SimpleAgentWithCompaction when the latest model response has no tool calls, including reasoning-only and empty responses. Previously, an untruncated reasoning-only response triggered another assistant turn without any intervening user message or tool result. This could repeat until the context was exhausted.

The agents now warn explicitly, mark the returned response and captured invocation incomplete, and preserve the model output and usage. Saved response metadata contains ng_termination_reason (incomplete_reasoning or empty_output) and ng_termination_message with the diagnosis. Existing metadata is preserved. Length truncation and content filtering retain their earlier incomplete_details handling; tool-call continuation and verifier-controlled rewards are unchanged.

Revisits the continuation behavior introduced in #19. No separate issue is needed for this focused bug fix.

Validation

Rebased onto main at 64bf158da.

  • Both agent suites: 68 passed, including empty/reasoning-only termination, tool continuation, usage accumulation, and metadata persistence through /run with verification enabled or skipped and trajectory capture disabled.
  • pre-commit run --all-files: passed.
  • git diff --check: passed.
  • All commits have DCO sign-off.

Tests used the existing Gym virtual environment with namespace imports explicitly bound to this worktree to avoid testing its original editable checkout:

import pathlib
import responses_api_agents
responses_api_agents.__path__ = [str(pathlib.Path.cwd() / "responses_api_agents")]
import responses_api_agents.simple_agent.app
import responses_api_agents.simple_agent_with_compaction.app
import pytest
raise SystemExit(pytest.main([
    "responses_api_agents/simple_agent/tests",
    "responses_api_agents/simple_agent_with_compaction/tests", "-q",
]))

Rollouts

A captured GPQA no-tools episode made 11 model calls and accumulated 284,835 output tokens. Its first response contained 6,218 output tokens, reasoning only, and no incomplete_details. Replaying that captured response through both patched agents stopped after one call, preserved the reasoning and usage, and marked the invocation incomplete.

A fresh end-to-end GPQA smoke test completed successfully using this PR.

  • 8/8 rollouts complete, no failed, missing, duplicate, or unscored rows. This is one GPQA question with eight repeats, not a full benchmark score.
  • Disabled the current GPQA one-step guard with max_steps=0, retained uncapped output/full 262,144-token context and the recipe's temperature 1 / top-p 0.95.
  • Provider response statistics: 8 stop, 0 length.
  • 4 incomplete-reasoning responses: each stopped after one model call, saved status=incomplete and ng_termination_reason=incomplete_reasoning, and received reward 0 from the normal MCQA verifier.
  • 4 normal answers: each received reward 1. All eight trajectories had exactly one unique policy-model call; saved outputs and usage exactly matched their captured model response.
  • Directly reviewed five selected generations, including three flagged responses and two normal answers. Mean output tokens: 1,223. The 4/8 correctness result is only a smoke-test observation.

Compatibility and benchmark impact

No configuration migration. Intentional behavior change: reasoning-only or empty responses no longer receive extra assistant turns to recover. Scores and token totals can therefore differ from previous runs. Consumers can identify these terminations via response.status and response.metadata; they are not mislabeled as max_output_tokens. Rewards remain determined by the existing verifier.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; no unrelated edits.
  • Tests added or updated and pass locally.
  • Documentation N/A: no configuration changes; output contract and benchmark impact documented above.
  • Pre-commit checks pass locally (pre-commit run --all-files).
  • No new source files; existing SPDX headers preserved.
  • All commits have DCO sign-off (git commit -s).

Signed-off-by: Igor Gitman <igitman@nvidia.com>
Signed-off-by: Igor Gitman <igitman@nvidia.com>
Signed-off-by: Igor Gitman <igitman@nvidia.com>
Signed-off-by: Igor Gitman <igitman@nvidia.com>
Signed-off-by: Igor Gitman <igitman@nvidia.com>
Signed-off-by: Igor Gitman <igitman@nvidia.com>
@Kipok Kipok added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior labels Sep 18, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 18, 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.

@Kipok
Kipok marked this pull request as ready for review September 18, 2026 18:20
@Kipok Kipok added the needs-review PR is ready for code review and waiting on a reviewer label Sep 18, 2026
@yaoyu-33 yaoyu-33 added the complexity:low Localized change in one scope with a small, straightforward review surface label Sep 18, 2026
@bxyu-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 49d3e4f

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team September 18, 2026 19:56
@bxyu-nvidia
bxyu-nvidia merged commit 711f23d into main Sep 18, 2026
51 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the codex/stop-reasoning-only-turns branch September 18, 2026 20:13

This branch was previously deployed

1 inactive deployment
public — 49d3e4f3 Deployed Sep 18, 2026 by copy-pr-bot[bot] via release / finalize / notify #3175
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 complexity:low Localized change in one scope with a small, straightforward 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.

3 participants