Repository navigation
Reduce repeated tool-list checks for concurrent runs of one agent - #6243
Draft
markstuart-oai wants to merge 1 commit into
Draft
markstuart-oai wants to merge 1 commit into
markstuart-oai wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Summary
In an offline replay of 32 overlapping text requests on one
Agent, this change has been cutting median latency per caller by 17.7% (11.88 to 9.70 ms) and p95 by 5.5%. On main, each caller has been comparing the live tool list with every active caller's list on every read.The patch has been checking every snapshot under the existing lock on registration. After a successful check, readers have been comparing the live tool identities and their order with one snapshot. Readers have been falling back to the full scan after an interrupted registration or a conflict. Each run has been keeping its own context and approval state.
Test plan
Two regression tests have been covering a join after a conflict and an interrupted registration. Both have been checking rejection after restoring the original list.
The full Agents verifier on Linux and Python 3.12 with the stock client has been passing 12,872 tests, with 30 skips. Formatting, linting, Pyright and mypy have been passing.
The text workload has been using an empty tool list and a local model returning a prebuilt reply. With eight callers, median latency has been falling by 5.2%. With one caller, the interval has been spanning zero.
In a second offline workload, each caller has been sending a distinct input and running one tool between two model replies. The tool has been changing a context variable. Each caller has been checking its own output and context afterward.
The tool benchmark has been using 36 balanced blocks with the patch and two identical main controls. All four p95 intervals against the first control have been spanning zero.
With the public Responses client and intercepted HTTP, 32 callers have been seeing smaller gains. The first 24 blocks have been showing median reductions of 7.28% for text and 2.75% for one tool. Both p95 intervals have been spanning zero and +3%.
In a fresh 192-block replay, the text median has been falling by 5.62% [4.99, 6.14] and the one-tool median by 2.46% [1.85, 3.08]. Text p95 has been changing by −2.80% [−5.56, −1.01] and one-tool p95 by +0.12% [−2.35, +2.84]. Request bodies, tool effects, outputs and caller contexts have been matching main. These tests have been excluding network and inference time.
For one tool, the second stock control has been running 0.36% slower at the median. The patch has been running 2.72% faster than that control.
The broader offline run has been using Python 3.12 with
openai==3.59.0, Codex off, and6afdd47bas the baseline. All 83 median upper bounds have been staying below +3%. The comparisons have been using 32 process pairs or a fresh 64-pair follow-up. I have been reporting the median percentage change within pairs and bootstrapping whole pairs for each 95% interval.In eight cases, the individual 95% intervals have been showing small increases. The estimates have been ranging from 0.38% to 1.18%, with the largest on a reused stream. For retained history, the larger replay has been showing a 0.44% increase for the patch and 0.48% between identical main builds.
In a separate profile, two of those eight workloads have been making zero calls to the changed functions during measurement. The other six have been reaching them with a single reader. This has been leaving the cause of those small increases uncertain.
In a separate one-tool startup check, 36 blocks using distinct package paths have been suggesting a 2% slowdown. Across 192 fresh blocks using one path for all builds, the first-answer changes have been +0.69% [−0.39, +1.54] and +0.06% [−0.83, +1.17] against the two stock controls. Warm median and p95 upper bounds in this replay have been staying below +1.1%.
Of 47 p95 estimates, four have been showing initial upper bounds above +3%. In a separate 192-pair replay, all four have been staying within the threshold. That replay has also been comparing identical copies of main.
All 83 median comparisons
cold_normalcold_streamids_17x32769ids_17x32769_streamids_3x8193ids_3x8193_streamreuse_normalreuse_streamtyped_3x257typed_3x257_streamadd_toolbuild_dict_12build_omitted_12build_typed_12con1con32con8diag_32h128handoffs_0handoffs_12history120history2000history720mixed_6nested67_stream16repeat_8retained_16384retained_2048run_dict_6run_omitted_6run_typed_6schemas_24server_1server_1024server_128server_512single_0single_12streamsustained_32time_1024_4096time_16384_2time_2048_2time_2_256time_4096_8tools1tools16tools4warmbatch-compare 1x1024batch-compare 2x32bulk-live 12x64bulk-live 1x1024bulk-live 1x2048bulk-live 1x256combo5 4x1024combo5 8x128concurrent5 2x128first-final 1x0first-mcp 1x0lists-final 1x1024lists-final 8x8192provider-final 1x2048provider-final 1x4096quote-final 1x1quote-final 1x64quote-final 8x16quote-final 8x256quote-final 8x64shape-local normal 12x96shape-local stream 12x96shape-local stream 4x12shape-local stream 8x0tail 4x1024values-final ids 1x1values-final ids 8x8192values-final last 4x512values-final records 8x512values-final typed 16x1024values-final typed 4x128warm-control 1x0warm-control 1x4096Checks
.agents/skills/code-change-verification/scripts/run.sh