NVIDIA-NeMo / NVIDIA-NeMo/Gym

Bypass agent loopback HTTP self-calls while preserving session behavior

Open
#3,012 0 comments 0 reactions 0 assignees View on GitHub

@ananthsub is already working on this.

Since May 28, 2026.

  • #1439 by @ananthsub — open
agents
Dominant language
Python
Stars
1.2k
Forks
349
Avg merge
1d 21h
Merged PRs (30d)
318

Description

Parent workstream: #3000

Slowdown path

flowchart LR
    A[Agent run] --> B[Loopback HTTP POST]
    B --> C[Agent middleware and validation]
    C --> D[Episode loop]
    D --> E[HTTP response parse]

Current behavior

SimpleAgent.run posts body.responses_create_params to the same agent server's /v1/responses route, waits for HTTP status, parses the JSON response, and recovers cookies. See SimpleAgent.run.

The self-call is not a simple function substitution. SimpleResponsesAPIAgent.setup_webserver registers rollout-prefixed route twins, and SimpleAgent.responses propagates model/resources cookies and optional trajectory data. See SimpleResponsesAPIAgent.setup_webserver and SimpleAgent.responses.

Impact and provenance

Measured

PR #1439 reports end-to-end throughput improvements of 7.5% for simple_agent and 13.3% for proof_refinement_agent in its original real-OpenAI-model measurements. These are the PR's measurements, not new measurements and not guaranteed for other agents or production workloads.

Expected

An in-process path should remove one loopback serialization/parse cycle, one middleware traversal, and associated socket pressure per self-call. Agents that self-call repeatedly may benefit more, but that remains workload-dependent.

Implementation constraints

  • Preserve public /v1/responses behavior for external callers.
  • Explicitly propagate resources/model cookies, rollout ID and URL correlation, token capture, model-call capture, trajectory data, telemetry, status/error semantics, and cancellation behavior.
  • Cover every production agent that self-calls; do not introduce divergent helper contracts per agent.
  • Keep downstream agent → model and agent → resources HTTP trust boundaries intact.

Acceptance criteria

  • Production agents no longer POST to their own /v1/responses endpoint.
  • External /v1/responses routes and rollout-prefixed variants remain compatible.
  • Stateful resources-server sessions and cookie updates survive multi-step rollouts.
  • Evaluation/model-call capture, training token capture, trajectories, retries, errors, and cancellation retain parity.
  • An audit test prevents new production self-calls.

Benchmark plan

Run alternating baseline/candidate end-to-end rollouts for simple_agent and a repeatedly self-calling agent such as proof_refinement_agent. Measure rollouts/s, p50/p99 latency, loopback requests, open sockets, CPU time, and failures at low and high concurrency. Include stateful resource sessions, capture enabled/disabled, and representative failure paths.

Related work/PRs

  • Parent: #3000
  • Direct implementation: #1439

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SimpleAgent.run and SimpleAgent.responses in responses_api_agents/simple_agent/app.py, then compare them with SimpleResponsesAPIAgent.setup_webserver in nemo_gym/base_responses_api_agent.py. Review direct implementation PR #1439 and the parent workstream #3000 before making changes. Done means production self-calls are removed while external routes, stateful sessions, captures, telemetry, errors, cancellation, and the listed benchmark cases retain parity.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.