perf: bypass HTTP self-call from /run to /v1/responses#1439
Open
ananthsub wants to merge 1 commit into
Open
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
9dc0d1c to
ed66904
Compare
…sponses Each agent's `/run` handler previously made an HTTP self-call to its own `/v1/responses` endpoint, paying for aiohttp round-trip, FastAPI middleware, and pydantic re-validation on every rollout. This converts all production agents that still did this to call the implementation in-process. The refactor extracts the existing `responses()` body into a private `_responses(body, cookies) -> (response, set_cookies)` helper. The public `responses(request, response, body)` method keeps its FastAPI signature and is now a 4-line adapter that delegates to `_responses`, so external HTTP callers see no change. `/run` replaces the 7-line self-call block with two lines that call `_responses` directly. Agents converted: simple_agent, proof_refinement_agent, non_executing_simple_agent, speed_bench_agent, cvdp_agent, finance_agent, browsecomp_agent, hermes_agent, claude_code_agent, and the langgraph_agent base + 4 subclasses (rewoo, orchestrator, parallel_thinking, reflection). swe_agents, aviary_agent, verifiers_agent, and stirrup_agent were already on this pattern. Microbenchmark shows ~0.7-1.2 ms framework overhead per self-call at concurrency=1, scaling to a ~70-150x rps multiplier in the LLM-overhead-isolated case. End-to-end with a mock model: simple_agent +25% rps / 20% wall-time reduction; proof_refinement_agent (3 self-calls per rollout) up to +2x rps / 50% wall-time reduction at concurrency=256. With a real OpenAI model in the loop the absolute per-rollout savings carry over (~7% rps on simple, ~13% on pref) and the HTTP path also hit FD exhaustion at concurrency=1024 where the in-process path did not. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
ed66904 to
75473cb
Compare
Contributor
|
Did you run training or benchmarks to confirm no accuracy or convergence degradation? Seems fine to me otherwise, although the logic around cookies seems to change a bit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each agent's
/runhandler currently makes an HTTP self-call to its own/v1/responsesendpoint. This adds extra aiohttp round-trip + FastAPI middleware + pydantic re-validation on every rollout.This PR converts all production agents that still do this to call the implementation in-process.
To keep backwards compatibility, the refactor extracts the existing
responses()body into a private helper. The publicresponses(request, response, body)method keeps its FastAPI signature.Microbenchmarks:
simple_agentproof_refinement_agent