Skip to content

test(proxy): drive the sweep's warm path on Bob's route (#1191) - #1192

Merged
amiddavid merged 2 commits into
mainfrom
test/bob-sweep-warm-path
Nov 21, 2026
Merged

amiddavid merged 2 commits into
mainfrom
test/bob-sweep-warm-path

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

No behavior change. This PR adds one test and changes no code. Data dependence: none (test only, no feature).

Summary

PR 1 of the plan in #1191. A test drives the sweep's warm path end to end through the proxy, on Bob's route, with the real bob-ultrahigh preset and Bob's real prices. It expects one sweep question, sent to Bob's model path with Bob's Apikey login. It fails on main today, so it is skipped with #1191. The fix PRs remove the skip.

What changed

  • New proxy/bobsweep_test.go:
    • A fake Bob upstream. It records path, Authorization and body. It bills about 1.5× the local size and reports most of the prompt as a cache read, as both Bob backends do.
    • A handler with proxy/testdata/bob_ultrahigh.yaml and bob-plugin/context-guru/prices.yaml.
    • One Bob chat of 64 turns (one X-Task-Id). It starts with a large grep result, then 63 small tool calls.
    • TestBobUltrahighSweepAsksBobOnALongChat: waits (testutil.WaitForState) for a body with the sweep question. Then it checks the path and the auth scheme. On failure it prints the sweep's warm and ping counters.

How it was tested

Run Result
main as is Fails: ping: not_registered 64, trigger_reasons map[]
Blocker 1 removed only (by a local patch, not committed) Fails: ping: not_registered 64, warm: not_registered 1
Blocker 2 removed only Fails: trigger_reasons map[] (every request cold)
Both removed Passes (0.67 s)
As committed (skipped) --- SKIP; make lint clean; go test ./proxy/ ok

So each blocker alone stops the sweep, and the test passes when both are fixed.

What we found while writing it

  1. extract_llm cuts a large source-file read on the first turn. Its model-free window keeps 4,000 characters. So the sweep never sees that output. The test uses a grep result instead, because extract_llm treats it as fact-dense and leaves it whole (components/offload/contentclass.go). This is the preset working as designed. It means that on Bob, the sweep can only work on what extract_llm leaves.
  2. With the defaults, the first sweep question comes at about turn 60, not 30. The trigger first checks when the warm count reaches warm_every_n (30). At that time the first tool output has only 29 later model turns, and warm_min_age_turns is 30. The count then restarts, so the next check is at about turn 60. This adds to blocker 3 in bob-ultrahigh: 3 blockers stop the sweep on Bob (no copy without a ping, every request cold, 30-turn defaults) #1191.

Why skip, not merge red

A red test breaks CI for every PR. The skip names #1191. PRs 2 and 3 of #1191 remove it, and the test then proves the fix end to end.

Assisted-By: Claude (Anthropic AI) [email protected]

A 64-turn Bob chat on bob-ultrahigh, with Bob's prices and a large, old
grep output, must get one sweep question at Bob's model path with Bob's
Apikey login. It fails on main on 2 blockers, each one enough alone: no
conversation copy without a ping, and every Bob request counted cold.
Skipped with #1191 until the fix PRs remove the skip.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 aa4bd29fe3fe approve

Verdict: approve

Findings

None. The PR adds one test file and changes no code. The test is skipped with a reason and a linked issue (#1191), as the repo rules require.

Non-blocking

  • proxy/bobsweep_test.go:150 — the test waits for len(up.questions()) > 0. The header comment and the PR say "one sweep question". If the fix PRs want to prove "exactly one", add a check after the wait (with 64 turns, the next check comes at about turn 90, so a second question is a defect). Polling for "== 1" is racy, so check it after the loop, not in the wait.
  • proxy/bobsweep_test.go:154 — the failure message prints w.TriggerReasons as the full process total, but the other values as deltas from before. Other tests in the package can add to that map. A delta, or a note in the message, makes the diagnosis clearer.
  • proxy/bobsweep_test.go:158 — the test checks path and auth, but not the question's model. A check that the question uses premium-ide (or the model the fix intends) would also catch a wrong-model route on Bob.
  • I could not confirm the PR's table of runs (fails on main, passes with both blockers fixed). Go is not installed here, and live tests are not approved.

What I checked

  • The full diff (166 lines, one new file) and the commit message (DCO sign-off and Assisted-By: present).
  • Every helper the test uses exists with the right signature in the proxy test package: bobPreset (bobdefer_test.go:106), bobFixtureTools (bobdefer_test.go:43), csCall (tooldefer_search_test.go:87), itoa (prefixask_test.go:61), authScheme (agentmodel_test.go:279), bobModelPath (proxy.go:747).
  • Library calls: offload.SweepWarmCounters / SweepPingCounters and the fields Fired, Asked, NotRegistered, TriggerReasons; testutil.WaitForState(t, what, cond, state); modelinfo.LoadTable returns *Table, and *Table has Price, so it satisfies Options.Prices (modelinfo.Pricer); tooldefer.FileName; store.NewMemory(store.Options{}); Handler.Close and Handler.Mux.
  • sweepQuestionMark matches the text that internal/extract/adjudicate.go:239 (BuildPrefixAsk) writes, so the comment's reference is right.
  • proxy/testdata/bob_ultrahigh.yaml turns on extract_llm_sweep with warm: true and min_tokens: 1000. The grep output (600 lines, about 36 KB) is far above that.
  • The defaults the comment names are real: defaultWarmEveryN = 30, defaultWarmMinAgeTurns = 30 (components/offload/extract_sweep_warm.go:44-45). The turn-60 reasoning agrees with them.
  • bob-plugin/context-guru/prices.yaml has a premium-ide row, so the request model has a price.
  • The JSON the test builds: the \\n in the grep format string and the \\( in the tool argument both give valid JSON escapes. The fake upstream's cached_tokens = prompt-50 stays positive, because the smallest prompt carries the full grep.
  • The fake key bob-caller-key is a placeholder. The failure message prints only the auth scheme, not the value.
  • Fail open and data dependence: not affected (test only, no feature).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 aa4bd29fe3fe approve

Verdict: approve

Findings

None.

Non-blocking

  • The test does not run yet. t.Skip at proxy/bobsweep_test.go:124 is the first statement, so the PR adds no coverage until a fix PR of #1191 removes the skip. The skip has a reason and a linked open issue, so it follows the rules. I could not confirm the claim "fails on main today" for the intended reason, because live tests are not approved. The fix PR that removes the skip must show the test fail before its fix and pass after.
  • 2 blockers in the test, 3 in the issue. The comment at lines 121-123 names 2 blockers. Issue #1191 names 3 ("30-turn defaults" is the third). The test steps around the third with 64 turns (lines 132-134). Say so in the comment, so the fix PR for the defaults knows that this test does not cover it.
  • The turn-30 comment may not match the trigger. Lines 132-134 say the count "restarts" after a check with no candidate. If the trigger instead checks again on each next turn, the question comes at about turn 31, not 60. The test passes either way (it only waits for one question by turn 64). Only the comment can be wrong.
  • bobSweepHandler (lines 69-87) is a copy of the handler set-up in bobdefer_test.go:92-104, with only Prices changed. A shared helper with a Prices argument would keep the two in step. Small point.
  • The failure message at line 164 prints only the auth scheme (authScheme), not the key. Good.

What I checked

  • Read every line of the only changed file, proxy/bobsweep_test.go (166 new lines), and the commit message.
  • No behavior change: test-only PR. No data-dependence row is needed (no feature or component change).
  • Every helper it uses exists in package proxy with the used signature: bobPreset, bobFixtureTools (bobdefer_test.go), csCall (tooldefer_search_test.go:87), itoa (prefixask_test.go:61), authScheme (agentmodel_test.go:279), bobModelPath (proxy.go:747).
  • Library calls match: offload.SweepWarmCounters (fields Fired, Asked, NotRegistered, TriggerReasons), offload.SweepPingCounters (NotRegistered), testutil.WaitForState(t, what, cond, state), modelinfo.LoadTable, tooldefer.FileName, Options.BobUpstream/ToolDeferPath/Prices, Handler.Close/Mux. All imports are used.
  • JSON escapes are valid: the grep lines use \\n in a Go string, so JSON gets \n. csCall quotes the arguments with %q, so serve\\(w, r becomes a valid JSON \\.
  • bob-plugin/context-guru/prices.yaml exists and prices premium-ide. The preset proxy/testdata/bob_ultrahigh.yaml turns on extract_llm_sweep with warm: true. The defaults warm_every_n and warm_min_age_turns are 30 (extract_sweep_warm.go:44-45), as the comment says.
  • The fake upstream uses the sweepQuestionMark line to find sweep questions. The normal Bob request bodies do not hold that text.
  • Issue #1191 is open.

Round 1 review of #1192: the test now checks exactly 1 question and
the question's model, prints the trigger reasons as deltas, and says
that #1191's blocker 3 is not covered. bobDeferHandlerBare and the
sweep test share one priced Bob handler.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. Both reviewers approved; the non-blocking points are answered here. The fixes are in 810f30c.

Reviewer 1

  1. Check exactly one question. Fixed. After the wait, the test asserts len(qs) == 1. No request follows the 64 turns, so no second question can start.
  2. Trigger reasons are a process total. Fixed. The failure message now prints them as deltas from before, like the other counters.
  3. Check the question's model. Fixed. The test asserts model == "premium-ide", the chat's own model.
  4. Run table not confirmed. Re-run on 810f30c, with a local patch that is not committed:
    • skip removed, main code: fails, ping: not_registered 64, trigger_reasons map[];
    • skip removed, both blockers patched out: passes (0.67 s), with the new checks.
    • As committed: make lint clean, go test ./proxy/ ok.

Reviewer 2

  1. The test does not run yet. Agreed, and intended. The fix PR that removes the skip will show it fail before its fix and pass after.
  2. 2 blockers in the test, 3 in the issue. Fixed. The comment now says that blocker 3 is not covered.
  3. The count may not restart after a check. Rejected, with proof. warmStep sets t.count = 0 before warmWorthAsking, under the comment "The count restarts here whether or not a question follows" (components/offload/extract_sweep_warm.go:921-925). On a 40-turn run, trigger_reasons showed exactly 1 check (no_candidate:1), not one per turn after turn 30.
  4. bobSweepHandler copies the Bob handler set-up. Fixed. A shared bobHandlerPriced(t, preset, upstream, prices); bobDeferHandlerBare calls it with tdPrices{}.

Assisted-By: Claude (Anthropic AI) [email protected]

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 810f30c5f3ad approve

Verdict: approve

Findings

None.

Earlier points

Both round-1 reviews had no findings. Status of the non-blocking points:

Reviewer 1

  1. Check exactly 1 question: fixed (bobsweep_test.go:152-155).
  2. Trigger reasons as a process total: fixed. The message now prints deltas from before (lines 140-145). A read from a nil before.TriggerReasons map gives 0, so this is safe.
  3. Check the question's model: fixed (lines 157-159).
  4. Run table not confirmed: the author reports a local run (fails on main with ping: not_registered 64, passes with both blockers patched out). I cannot confirm it. Live tests are not approved.

Reviewer 2 (mine)

  1. The test does not run yet: accepted as intended. The fix PR removes the skip.
  2. 2 blockers in the test, 3 in the issue: fixed (line 108).
  3. The count may not restart: rejected by the author, and the reason is right. extract_sweep_warm.go:921-926 sets t.count = 0 before warmWorthAsking, under the comment "The count restarts here whether or not a question follows". So the check at about turn 30 finds no candidate, and the next check is at about turn 60. The test comment is correct. I withdraw the point.
  4. Copied handler set-up: fixed. bobHandlerPriced (bobdefer_test.go:96-112) holds the set-up. bobDeferHandlerBare and bobSweepHandler both call it.

Non-blocking

  • The "exactly 1" check (line 152) runs right after the first question arrives. A second question that is still in flight at that time is not seen. Today this cannot happen, because the next check is due at about turn 90. If a fix PR makes the trigger fire more often, this check can miss it. It cannot give a false failure.

What I checked

  • Last review: round 1, aa4bd29, 2026-11-17T09:40:33Z
  • New commits read: 1 (810f30c "test(proxy): check one question, its model; share the Bob handler")
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review: 1 author comment (2026-11-17T09:45:53Z) with replies to both reviews. I checked each reply against the code, as listed under "Earlier points".
  • Read the full diff aa4bd29f..810f30c5 (2 files, +27 -20), and the code around it in bobdefer_test.go:60-112.
  • Imports: bobsweep_test.go drops config, metrics, store, tooldefer, which it no longer uses. It still uses filepath, modelinfo, strings, sync, gjson. bobdefer_test.go adds modelinfo for the new prices modelinfo.Pricer parameter.
  • tdPrices{} was already passed as Options.Prices, so it satisfies modelinfo.Pricer. bobDeferHandler behaves the same as before.
  • No typed-nil risk: modelinfo.LoadTable returns *Table. On an error, t.Fatal stops the test before the value is passed.
  • The model check matches the request: bobSweepBody sends "model":"premium-ide".
  • Test only. No behavior change and no data-dependence change.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 810f30c5f3ad approve

Verdict: approve

Findings

None. The new commit fixes my 3 non-blocking points and 3 of reviewer 2's 4 points. The author rejected one point with a correct reason.

Status of earlier points

  • Reviewer 1, point 1 (exactly 1 question): fixed. proxy/bobsweep_test.go:150-154 checks len(qs) == 1 after the wait, not in the wait. That is not racy. The wait returns at the first question. A second question needs a second trigger, and the trigger restarts its count (see below), so a second question by turn 64 is a real defect.
  • Reviewer 1, point 2 (trigger reasons as totals): fixed. Lines 140-145 print deltas from before. The counters only grow, so a key in before is always in w too, and the loop over w.TriggerReasons does not miss one.
  • Reviewer 1, point 3 (question model): fixed. Line 157 checks model == "premium-ide".
  • Reviewer 1, point 4 (run table not confirmed): the author re-ran on 810f30c with a local patch and gave the results. I still cannot run Go here. This stays unverified by me. It is not a defect.
  • Reviewer 2, point 1 (the test does not run yet): the author agrees. The skip is intended, and the fix PR must show fail-then-pass. I agree.
  • Reviewer 2, point 2 (blocker 3 not named): fixed. Line 108 says that this test does not cover blocker 3.
  • Reviewer 2, point 3 (the count may not restart): rejected by the author. The reason is correct. components/offload/extract_sweep_warm.go:921-927 sets t.count = 0 before warmWorthAsking, under the comment "The count restarts here whether or not a question follows". So the check at about turn 30 resets the count, and the next check comes at about turn 60. The comment at lines 118-120 is right.
  • Reviewer 2, point 4 (copied handler set-up): fixed. bobHandlerPriced (proxy/bobdefer_test.go:95-109) holds the set-up. bobDeferHandlerBare calls it with tdPrices{}, so its behavior does not change. bobSweepHandler calls it with the loaded price table.

Non-blocking

  • None new.

What I checked

  • Last review: round 1, aa4bd29, 2026-11-17T09:40:18Z
  • New commits read: 1 (810f30c5 test(proxy): check one question, its model; share the Bob handler)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-1 review (09:40:33Z): read each of its 4 points. Checked the author's answer to each, above.
    • The author's round-1 replies (09:45:53Z): checked each claimed fix in the diff. Checked the rejection of reviewer 2's point 3 against extract_sweep_warm.go:921-927.
  • The full diff aa4bd29f..810f30c5 (2 files, +27 −20), and the code around each change.
  • Imports: bobsweep_test.go drops config, metrics, store, tooldefer. None of them has a use left in the file. gjson, modelinfo, testutil and offload still have uses. bobdefer_test.go adds modelinfo for the modelinfo.Pricer argument.
  • *modelinfo.Table and tdPrices both satisfy modelinfo.Pricer. The other callers that build their own handler with tdPrices{} (tooldefer_search_test.go:103, tooldefer_866_test.go:99) do not change.
  • The commit has a DCO sign-off and an Assisted-By: line.
  • Test only: no behavior change, no data-dependence change, fail-open not affected.

@amiddavid
amiddavid merged commit 0aa9070 into main Nov 21, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants