Skip to content

Simple agent stop criteria requires no tool calls AND output message item to be present - #19

Merged
bxyu-nvidia merged 4 commits into
mainfrom
bxyu/simple-agent-stop-criteria
Sep 9, 2025
Merged

bxyu-nvidia merged 4 commits into
mainfrom
bxyu/simple-agent-stop-criteria

Conversation

@bxyu-nvidia

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Brian Yu <bxyu@nvidia.com>
@bxyu-nvidia
bxyu-nvidia merged commit 9dc94e3 into main Sep 9, 2025
@bxyu-nvidia
bxyu-nvidia deleted the bxyu/simple-agent-stop-criteria branch September 9, 2025 05:08
abhibha-nvidia pushed a commit that referenced this pull request Sep 28, 2025
…item to be present (#19)

Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Abhibha Gupta <abhibhag@nvidia.com>
abhibha-nvidia pushed a commit that referenced this pull request Sep 29, 2025
…item to be present (#19)

Signed-off-by: Brian Yu <bxyu@nvidia.com>
Signed-off-by: Abhibha Gupta <abhibhag@nvidia.com>
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
…item to be present (NVIDIA-NeMo#19)

Signed-off-by: Brian Yu <bxyu@nvidia.com>
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
…item to be present (NVIDIA-NeMo#19)

Signed-off-by: Brian Yu <bxyu@nvidia.com>
bxyu-nvidia pushed a commit that referenced this pull request Sep 18, 2026
## 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:

```python
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

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

---------

Signed-off-by: Igor Gitman <igitman@nvidia.com>

This branch was previously deployed

2 inactive deployments
nemo-ci — 700e4de5 Deployed Sep 8, 2025 by copy-pr-bot[bot]
test — 700e4de5 Deployed Sep 8, 2025 by copy-pr-bot[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant