Repository navigation
test(proxy): wait for the detached calls in the remaining agentmodel tests (#1110) - #1132
Merged
Merged
Conversation
amiddavid
force-pushed
the
test/agentmodel-wait-more
branch
from
November 12, 2026 11:41
f62331c to
5fca0a2
Compare
…tests (#1110) The panic and malformed-target tests read the summary call once, right after the response. They now wait, with a time limit, until the summary call arrives, then wait for every detached summary to end. The request helper also drains summaries that an earlier test left running. Test only. No behavior change. Data dependence: none. Fixes #1110. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
force-pushed
the
test/agentmodel-wait-more
branch
from
November 12, 2026 11:57
5fca0a2 to
db1b347
Compare
amiddavid
commented
Nov 12, 2026
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | db1b34718c1b |
approve |
Verdict: approve
Findings
None.
Non-blocking
- proxy/agentmodel_test.go:157, 178, 309 — three tests that want one summary call still read a fixed snapshot.
TestBobSummaryCallUsesBobsModelPathAndApikey,TestOpenAISummaryCallTargetIsUnchangedandTestOpenAIRouteStillFallsBackToTheOperatorsKeyread the calls thatpostSummarizablereturns.TestOpenAISummaryCallTargetIsUnchangedis one of the two tests #1110 names. The new comment onawaitSummaryCalls(line 135) says "A test that wants a call must use it". I traced the timing and these three are safe today:inFlight.beginruns inside the pipeline, before the proxy answers (proxy/proxy.go:1523runsapplyModebefore the forward); the fake upstream records the call in the goroutine body, before the deferredinFlight.finish(components/offload/summarize_async.go:267-268);WaitForAllSummariesForTestreads the same registry. So the drain cannot return before the call is recorded. The gap that remains for them is diagnosis only: on a decline they fail with "got 0 summary calls" and no state. Converting them would give one rule and a better failure text. - proxy/agentmodel_test.go:144 — the second wait is not deadline-aware.
testutil.WaitForStatecuts its bound to the test deadline minus 5 s, so its failure message shows. TheWaitForAllSummariesForTest(30 * time.Second)after it has no such cut. If a job hangs after the wanted calls arrived, thet.Fatalcan be replaced by a bare "test timed out". The window is narrow (the job ends right after the call and the commit), so this is minor.
What I checked
- The full diff (1 file, +31/−1) and both commits, line by line.
- The flake paths the change closes. A summary left over from an earlier test is the only decline the CI failure shape fits ("0 summary calls, all calls: 1" with the drain in place means
summarizenever commissioned):summary_already_in_flight(same derived session key, process-wide registry) andsummary_concurrency_full(8 process-wide slots). Both are drained by the new pre-wait, for everypostSummarizablecaller, not only the two converted tests. - The happens-before chain for the post-response drain, named under the first non-blocking item. The start-latency window the PR description names ("not started yet") cannot produce a 0-call result for a commissioned summary, because
beginruns before the response. awaitSummaryCallsitself: the poll condition and the state func are mutex-safe reads of the fake upstream;WaitForStatefails witht.Fatalfon the test goroutine; a second summary arriving before the final read is caught by thelen(got) != 1check with a clear message.- The want-0 tests (
TestBobRouteNeverSendsTheOperatorsOpenAIKey,TestAMisbehavingAgentRouteNeverSendsTheOperatorsOpenAIKey): their decline is decided during request handling (no_model,proxy/proxy.go:1106-1111), so no late summary can make them pass spuriously. - Scope and hygiene: no production file touched;
fmtandinternal/testutilimports are used;testutilis test-only by design and this is a_test.gofile; the helpers are used only in this file. No behavior change, data dependence none — matches the PR text. - I did not run the tests. Live runs are not approved for this review.
amiddavid
commented
Nov 12, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddaid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddaid's session | fresh | 1 of 2 | 1 of 2 | db1b34718c1b |
approve |
Verdict: approve
Findings
None.
Non-blocking
- proxy/agentmodel_test.go:157, 178, 309 — three tests that want one summary call still read a fixed snapshot.
TestBobSummaryCallUsesBobsModelPathAndApikey,TestOpenAISummaryCallTargetIsUnchangedandTestOpenAIRouteStillFallsBackToTheOperatorsKeyread the calls thatpostSummarizablereturns.TestOpenAISummaryCallTargetIsUnchangedis one of the two tests #1110 names. The new comment onawaitSummaryCalls(line 135) says "A test that wants a call must use it". I traced the timing and these three are safe today:inFlight.beginruns inside the pipeline, before the proxy answers (proxy/proxy.go:1523runsapplyModebefore the forward); the fake upstream records the call in the goroutine body, before the deferredinFlight.finish(components/offload/summarize_async.go:267-268);WaitForAllSummariesForTestreads the same registry. So the drain cannot return before the call is recorded. The gap that remains for them is diagnosis only: on a decline they fail with "got 0 summary calls" and no state. Converting them would give one rule and a better failure text. - proxy/agentmodel_test.go:144 — the second wait is not deadline-aware.
testutil.WaitForStatecuts its bound to the test deadline minus 5 s, so its failure message shows. TheWaitForAllSummariesForTest(30 * time.Second)after it has no such cut. If a job hangs after the wanted calls arrived, thet.Fatalcan be replaced by a bare "test timed out". The window is narrow (the job ends right after the call and the commit), so this is minor.
What I checked
- The full diff (1 file, +31/−1) and both commits, line by line.
- The flake paths the change closes. A summary left over from an earlier test is the only decline the CI failure shape fits ("0 summary calls, all calls: 1" with the drain in place means
summarizenever commissioned):summary_already_in_flight(same derived session key, process-wide registry) andsummary_concurrency_full(8 process-wide slots). Both are drained by the new pre-wait, for everypostSummarizablecaller, not only the two converted tests. - The happens-before chain for the post-response drain, named under the first non-blocking item. The start-latency window the PR description names ("not started yet") cannot produce a 0-call result for a commissioned summary, because
beginruns before the response. awaitSummaryCallsitself: the poll condition and the state func are mutex-safe reads of the fake upstream;WaitForStatefails witht.Fatalfon the test goroutine; a second summary arriving before the final read is caught by thelen(got) != 1check with a clear message.- The want-0 tests (
TestBobRouteNeverSendsTheOperatorsOpenAIKey,TestAMisbehavingAgentRouteNeverSendsTheOperatorsOpenAIKey): their decline is decided during request handling (no_model,proxy/proxy.go:1106-1111), so no late summary can make them pass spuriously. - Scope and hygiene: no production file touched;
fmtandinternal/testutilimports are used;testutilis test-only by design and this is a_test.gofile; the helpers are used only in this file. No behavior change, data dependence none — matches the PR text. - I did not run the tests. Live runs are not approved for this review.
amiddavid
commented
Nov 12, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | db1b34718c1b |
blocking |
Verdict: blocking
Findings
- proxy/agentmodel_test.go:178 — the issue's first named test keeps the one-shot read, so the fix for #1110 is incomplete
- What fails: issue #1110 names two flaky tests. This PR converts only one of them
(TestMalformedAgentModelTargetKeepsTheHostDefault, throughsummaryCallWith). The other,
TestOpenAISummaryCallTargetIsUnchanged, still reads the summary calls once, after only the
in-flight wait. The PR's own helper comment (agentmodel_test.go:133-136) states the rule:
"A test that wants a call must use it: the in-flight check alone cannot tell 'no summary
started' from 'the summary has not started yet'." Three want-a-call sites break that rule:
line 157 (TestBobSummaryCallUsesBobsModelPathAndApikey), line 178
(TestOpenAISummaryCallTargetIsUnchanged), and line 309
(TestOpenAIRouteStillFallsBackToTheOperatorsKey). If the CI flake of #1110 comes back, it
lands on line 178 first, with the old confusing message ("0 summary calls, want 1"), not the
new state-reporting one. - Proof: the failure message #1110 quotes for this test is "OpenAI upstream got 0 summary
calls, want 1; all calls: 1". The test at line 178 does not usesummaryCallWith, so it gets
only the new pre-drain, notawaitSummaryCalls. The pre-drain closes one decline path: a
summary already registered when the drain polls. It does not close a summary that registers
after the drain and before this request's commission (a deferred or observe-pool commission
another test left pending —WaitForAllSummariesForTestignores the deferred and dispatching
sets, which the PR body itself notes). In that casesummarizedeclines, the test reads 0
calls, and it fails exactly as #1110 reports. The PR body also says "Two agentmodel tests
read the upstream's calls once" — the issue's first named test is a third one, outside that
set. - Fix: pick one position and apply it everywhere. Either route lines 157, 178 and 309 through
awaitSummaryCalls(two lines per site, assummaryCallWithnow does), or keep the one-shot
read and state why it is safe for them: the commission happens inOffload, on the request
goroutine, before the forward (proxy/modes.go:57, components/offload/summarize.go:647), so a
commissioned summary is always in flight when the post-response drain runs. If the second
position holds, the helper comment's rule is wrong as written and should say so.
- What fails: issue #1110 names two flaky tests. This PR converts only one of them
Non-blocking
WaitForAllSummariesForTestdoes not wait out pending deferred commissions or the dispatching
set, unlikeWaitForSummaryForTest(components/offload/summarize_testhook.go:24-48 vs 64-76).
These tests run plainsummarize, which defers nothing, so it is harmless here. The PR body
says the same.summaryCallWithnow drains twice: once insidepostSummarizable, once inawaitSummaryCalls.
The second drain is nearly always instant. Harmless.- A declined summary in a
summaryCallWithtest now costs up to 30 s before the clear
WaitForStatefailure, where the base code failed at once with a confusing message. Better
diagnostics, slower failure. Acceptable.
What I checked
- Read both commits in full (c85063c, db1b347) and the diff against base abb77b1. One file
changed:proxy/agentmodel_test.go, test only. - Read every changed line and the code around it:
postSummarizable,summaryCallsOf,
awaitSummaryCalls,summaryCallWith, and all sixpostSummarizablecall sites. - Traced the wait chain:
offload.WaitForAllSummariesForTest(components/offload/summarize_testhook.go:64)
andtestutil.WaitForState(internal/testutil/testutil.go:45), including the bound, the
deadline margin and the panic-safe state func. - Traced the commission path to check the one-shot read's soundness: the proxy runs the pipeline
synchronously before the forward (proxy/proxy.go:1523, proxy/modes.go:57),Summarize.Offload
callsstartAsyncSummary(components/offload/summarize.go:647), andinFlight.beginregisters
the job before the request continues (components/offload/summarize_async.go:227, 136-150). So a
commissioned summary is in flight before the client sees a response, and the drain cannot miss
it. The only failure mode left for a want-a-call test is a decline, which needs a colliding
job: same conv key (session derived from the transcript, components/offload/state.go:543,
session/session.go:206 — all tests in this file share it) or a full global bound (8 slots). - Checked the contamination sources the pre-drain guards against: test files that run before
agentmodel_test.goin file order commission no summaries; observe-mode and cache-aware tests
that can commission late live in later files, so they matter only under-count>1, which is
the issue's own repro method. - Checked the want-zero tests (
TestBobRouteNeverSendsTheOperatorsOpenAIKey,
TestAMisbehavingAgentRouteNeverSendsTheOperatorsOpenAIKey): a one-shot read after the drain is
correct for them;awaitSummaryCallswould not fit a want-zero assertion. - Checked compile-level concerns:
fmtandinternal/testutilimports are used and allowed
(other proxy test files already importtestutil; the guard test targets production files). - Checked the process rules: test only, no behavior change, data dependence none, DCO sign-off
andAssisted-Bypresent on both commits, conventional-commit titles. - Did not run builds or tests: live tests are not approved for this review, and Go is not on
this machine.
…t tests (#1110) Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Collaborator
Author
|
Round 1 fixed. The three tests that wanted 1 summary call and still read once now use The two tests that want 0 calls keep the one-shot read after the drain, as reviewer 2 found sound. Box, |
amiddavid
commented
Nov 12, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 3ad22bdcdea7 |
approve |
Verdict: approve
Findings
None.
Earlier findings
- Reviewer 2, round 1, finding 1 (the three one-shot want-1 tests) — fixed. Commit
3ad22bdcroutesTestBobSummaryCallUsesBobsModelPathAndApikey,TestOpenAISummaryCallTargetIsUnchangedandTestOpenAIRouteStillFallsBackToTheOperatorsKeythroughawaitSummaryCalls(proxy/agentmodel_test.go:157-158,179-180,311-312). I checked the fix: every want-1 site now uses the wait, and the two want-0 tests keep the one-shot read, which is correct for them. This was also my round-1 non-blocking note 1, now resolved. The fix follows the first remedy reviewer 2 proposed, so the helper comment's rule and the code now agree. - My round-1 non-blocking note 2 (the second wait in
awaitSummaryCallsis not deadline-aware) — not addressed, still minor.proxy/agentmodel_test.go:144keeps the plain 30 s bound. The window is narrow and the failure text is only diagnostic, so this stays non-blocking.
Non-blocking
summaryCallWithand the three converted tests now drain twice per test: once at the end ofpostSummarizable, once insideawaitSummaryCalls. The second drain is nearly always instant. Harmless.- Reviewer 2's round-1 non-blocking note on
WaitForAllSummariesForTestignoring the deferred and dispatching sets still holds. These tests run plainsummarize, which defers nothing. No change needed.
What I checked
- Last review: round 1,
db1b34718c1b01d005662f43b9fed8dcddd4cf04, 2026-11-12T12:18:45Z. - New commits read: 3 —
192b5f65(merge oforigin/main),9d20eef3(#1091, from main),3ad22bdc(the fix).981c7eaf(#1119) also came in through the merge. - Read in full: 3 reviews, 1 comment, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Reviewer 2's round-1 review (12:41:36Z, blocking): read in full. Its finding names the same three sites as my round-1 note. I checked the fix against it (see "Earlier findings").
- The author's comment (12:46:32Z): read. It states the fix and the box result (
-race -count=100, pass). Nothing in it asks for more work. - The merge
192b5f65: verified clean.git diff 9d20eef3..192b5f65shows only this branch's test changes (+31/−1, one file), and the merge changes nothing inproxy/agentmodel_test.goagainst the branch parent. No hand resolution. The two main commits it brings (#1119, #1091) carry their own two-round reviews and are outside this PR's diff. - Commit
3ad22bdc: read the whole diff and the file around each change. The conversion is mechanical, the same patternsummaryCallWithalready uses. Thelen(got) != 1checks and their messages are kept.
- The PR diff against the new base
9d20eef3is one file,proxy/agentmodel_test.go, +37/−4. No production code, no behavior change, data dependence none. - Grepped every
postSummarizable/awaitSummaryCallscall site: 4 want-1 sites use the wait, 2 want-0 sites keep the one-shot read. - I did not run the tests. Live runs are not approved for this review.
amiddavid
commented
Nov 12, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 3ad22bdcdea7 |
approve |
Verdict: approve
Findings
None.
Earlier findings, this round
- My round-1 finding (agentmodel_test.go:178 — three want-a-call tests on the one-shot read):
fixed. Commit 3ad22bd routes all three sites throughawaitSummaryCalls(t, calls, 1):
TestBobSummaryCallUsesBobsModelPathAndApikey(line 158),
TestOpenAISummaryCallTargetIsUnchanged(line 180) — one of the two tests #1110 names — and
TestOpenAIRouteStillFallsBackToTheOperatorsKey(line 312). The pattern matches
summaryCallWith. The assertions are unchanged. The helper comment's rule ("a test that wants
a call must use it") now holds for every want-a-call site in the file. - Reviewer 1's non-blocking item, same three sites: fixed by the same commit. I checked it
myself; same proof as above. - Reviewer 1's non-blocking item (agentmodel_test.go:144 — the second wait is not
deadline-aware): not addressed, still non-blocking. TheWaitForAllSummariesForTest(30s)
afterWaitForStatestill has no deadline cut. The window is narrow (it starts only after the
wanted calls arrived), and three more tests now run this path, but a hung job there still ends
in a bare "test timed out" rather than the helper's message. Fine to leave.
Non-blocking
- The fix commit's message body is empty: no "Data dependence: none" line, unlike the two earlier
commits. The PR body carries the statement, and the change is test only. Not a problem. - The PR body's Update section says "Rebased on main with #1122". The merge (192b5f6) brings in
#1119 and #1091. A reader may look for the wrong PR number. Cosmetic.
What I checked
- Last review: round 1, db1b347, 2026-11-12T12:41:36Z.
- New commits read: 3 (192b5f6 "Merge remote-tracking branch 'origin/main' into
test/agentmodel-wait-more", which brings 981c7ea #1119 and 9d20eef #1091 from main;
3ad22bd "test(proxy): wait for the summary call in the three remaining one-shot tests
(#1110)"). - Read in full: 3 reviews, 1 comment, 0 inline comments (from the three files
.review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt). - New items since my last review, and what I did about each:
- Author comment at 12:46:32Z ("Round 1 fixed... -race -count=100... pass"): verified every
claim against the code. The three named tests do useawaitSummaryCallsnow. The two want-0
tests keep the one-shot read, which matches my round-1 analysis (a want-0 assertion cannot
useawaitSummaryCallsas written). - Fix commit 3ad22bd: read the full diff and the three changed tests in the file. Checked the
assertions are unchanged, the pattern matchessummaryCallWith,postSummarizable's return
is still used by the two want-0 tests (no dead code), and no other line of the file moved. - Merge 192b5f6: checked it does not touch
proxy/agentmodel_test.go(empty diffstat for the
file), and the PR diff against the new base 9d20eef is the test file only (+37/−4). The two
main commits it brings (#1119, #1091) touch store, tenancy, accountant and dash code, none of
which these tests or the summarize wait path read; both carried their own two review rounds.
- Author comment at 12:46:32Z ("Round 1 fixed... -race -count=100... pass"): verified every
- Re-checked the round-1 trace on the final head:
postSummarizablestill pre-drains and
post-drains;awaitSummaryCalls(lines 135-150) is unchanged since round 1. - Commit conventions on 3ad22bd: conventional title, DCO sign-off,
Assisted-By. Present. - Did not run builds or tests: live tests are not approved, and Go is not on this machine. The
author's box runs (-race -count=100, pass) are the author's report.
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
Two agentmodel tests read the upstream's calls once, right after the response. They now wait for the summary call, with a time limit. Test only.
What we found
TestPanickingAgentModelTargetFailsOpenToTheHostDefaultandTestMalformedAgentModelTargetKeepsTheHostDefaultusesummaryCallWith. It takes one snapshot of the calls.postSummarizablewait until no summary is in flight. That check cannot tell "no summary started" from "the summary has not started yet".summarizedecline the next test's summary.What changed
postSummarizablewaits for earlier summaries to end before it sends the request.awaitSummaryCalls: polls (2 ms) until the wanted summary calls arrive, 10 s limit. Then waits for all summaries to end, so a late extra call shows.summaryCallWithuses it. No fixed sleep.How it was tested
On the box,
-race, programs pinned to 2 CPUs, many copies in parallel.-count=300of the 2 tests (2,400 runs): 0 failures. The wider group at-count=2: pass.gofmt -landgo vet: clean.Test only. No behavior change. Data dependence: none.
Fixes #1110.
Update
testutil.WaitForState(30 s bound, reports the last state seen). No new helper.-race -count=100: pass.WaitForAllSummariesForTeststill ignores the deferred and dispatching sets. These tests use plainsummarize, which does not defer.