Skip to content

Bypass agent loopback HTTP self-calls while preserving session behavior #3012

Open

Description

@ananthsub

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]
Loading

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions