Skip to content

fix(anyswe_agent): request the training-token-capture prefix and run the inner harness in capture mode - #4016

Open
linj-glitch wants to merge 5 commits into
NVIDIA-NeMo:mainfrom
linj-glitch:linj/anyswe-token-capture
Open

linj-glitch wants to merge 5 commits into
NVIDIA-NeMo:mainfrom
linj-glitch:linj/anyswe-token-capture

Conversation

@linj-glitch

@linj-glitch linj-glitch commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

anyswe_agent runs an inner harness in a SWE task image. Training-token capture previously broke at three handoffs: the outer agent omitted the capture URL prefix, the inner runner did not enable capture, and the outer response replaced the inner served-response ID. This left rollouts with zero captured calls or no usable attribution.

The model URL now carries the training capture prefix when requested, the runner enables capture from that URL, and the outer response retains the inner ID only when the actual sandbox URL contains the capture segment. Direct requests without rollout indices and custom URLs without that segment retain evaluation behavior. The main integration also preserves #4836's trace context on URLs without a rollout ID.

The related tool-call-ID attribution change #4014 merged on October 16 and is included from main; it is no longer an outstanding merge dependency. No separate issue is needed for this focused repair.

Validation

Validated head: 391f8a62a774dad38858956bdc90ce2d18f496f8, including an additive merge of main f36e126547866601bee9c0671c9b59484ef83723. Python 3.13.14; before running pytest, the runner asserted that nemo_gym, responses_api_agents.anyswe_agent.app, and agent_runner were imported from the reviewed checkout.

  • Component suite with pytest -q -o addopts= --disable-warnings responses_api_agents/anyswe_agent/tests: 82 passed.
  • pre-commit run --all-files: passed; final PR diff whitespace checks passed and the worktree was clean.
  • All new commits carry DCO sign-off; updates are additive, without rewriting history.

The suite exercises the real run() → parameter setup → sandbox execution path, checks the URL given to the harness and the returned response ID with capture on/off, covers direct requests and custom URLs, and runs the actual runner construction path to verify the inner agent's capture setting. Existing model-name tests pass without a server_client on the test agent. Additional tests preserve trace context with and without a rollout ID.

Rollouts and compatibility

Historical author-reported Claude Code GRPO use on R2E-Gym: before these fixes, rollouts were masked because capture or attribution was missing; the combined fixes were subsequently used over several thousand training rollouts. No fresh model or sandbox rollout was run for this integration update, and no new end-to-end training-readiness claim is made.

Capture-off response IDs remain anyswe-<instance_id>. Capture-enabled responses use the inner served-response ID. Current-head CI and renewed maintainer review remain merge gates.

@copy-pr-bot

copy-pr-bot Bot commented Oct 4, 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.

@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior 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 labels Oct 5, 2026
@linj-glitch
linj-glitch marked this pull request as draft October 5, 2026 06:11
@linj-glitch
linj-glitch force-pushed the linj/anyswe-token-capture branch from a382130 to e04a68c Compare October 8, 2026 00:15
…the inner harness in capture mode

`_setup_params` built the in-sandbox model URL with
`apply_rollout_prefix(url, rollout_id)` and no `token_capture=` keyword, so
the harness only ever got the eval prefix `/ng-rollout/<id>`. With
`token_id_capture.enabled: true` the run looks healthy, but every rollout
reports `n_calls == 0` and is masked. NVIDIA-NeMo#3397 fixed the same bug in
anyterminal_agent. Pass `self._token_id_capture_enabled()`.

Two more gaps kept captured rollouts from being attributed:

- The in-sandbox runner built the inner agent's global config without a
  `token_id_capture` block, so the inner agent ran in eval mode. When the
  model URL carries the training-token-capture segment, the runner now
  enables capture for the inner agent.
- The outer response replaced the inner agent's id with
  `anyswe-<instance_id>`. Under capture, keep the inner id (the served id
  the inner agent reports) so terminal attribution can match it. Eval mode
  keeps the synthetic id.

Signed-off-by: Lin Jia <linj@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linj-glitch
linj-glitch force-pushed the linj/anyswe-token-capture branch from e04a68c to 4402c2f Compare October 8, 2026 00:20
@linj-glitch
linj-glitch marked this pull request as ready for review October 13, 2026 23:08
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 14, 2026
@pthombre
pthombre self-requested a review October 15, 2026 20:26
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 15, 2026
@pthombre

Copy link
Copy Markdown
Contributor

/ok to test 4402c2f

Signed-off-by: Lin Jia <linj@nvidia.com>
@pthombre

Copy link
Copy Markdown
Contributor

/ok to test 1d4013d

pthombre
pthombre previously approved these changes Oct 19, 2026
Signed-off-by: Lin Jia <linj@nvidia.com>
@linj-glitch

Copy link
Copy Markdown
Collaborator Author

/ok to test 391f8a6

This branch was previously deployed

1 inactive deployment
public — 391f8a62 Deployed Oct 24, 2026 by copy-pr-bot[bot] via release / finalize / notify #7053
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: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.

3 participants