Repository navigation
fix(plugin): the preset picker restarts the proxy after a yes, and the status shows a pending preset (#887) - #889
Conversation
…e status shows a pending preset (#887) `preset set` saved the preset but the running proxy kept the old one until the next session start, and nothing showed the gap. - `preset set` reads the running preset from /stats. If it differs, it says a restart costs one cache rewrite per open session and asks for a yes. It sends no probe to the old proxy. - New `preset restart --name X` runs start-proxy.sh (strategy sync, fingerprint compare, stop by pidfile, start), checks /stats, then sends the ultrahigh probe to the restarted proxy. - /stats gains an additive `preset` key. - `cg.py home` and the status line show "preset: xhigh (ultrahigh after a restart)" when saved and running presets differ. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 2ecd56737eb9 |
blocking |
Verdict: blocking
Findings
-
PR description — Missing behavior change disclosure required by CLAUDE.md
- What fails: Users with tool search on Chat Completions (GPT models, ultrahigh preset) lose streaming. The PR removes the splice path for Chat Completions and moves it to a fully buffered path. This is a behavior change that affects real users.
- Proof: CLAUDE.md states "No behavior change for an edge case without a human developer's permission. A fix that changes what the proxy or the library does for users or for other cases (a default, a time limit, what gets cached, offloaded or shown) needs a human developer's yes before it merges. This holds even when the change looks like a side effect of a narrow fix. Name the change at the top of the PR: who it affects, the old and the new behavior, and how to turn it off." The diff shows: (1) Line 2118 removes Chat Completions from the splice case, (2) Lines 2171-2180 add a new buffered case for
searchOn, (3) The comment says "The client loses its stream for the requests of a thread with deferred tools; see #825". The PR description must state: who (users with tool search on GPT models), old behavior (streamed with splice), new behavior (fully buffered), and how to turn it off (disable tool search or use a different preset). - Fix: Add the behavior change disclosure to the PR description and get approval from a human developer before merge.
-
proxy/proxy.go:2133 — Condition change from
!sp.opened()tosp.blocks == 0needs verification- What fails: The condition that determines if a response is buffered changed. The old
opened()method checkedsp.said || sp.blocks > 0for Chat Completions. The new check is onlysp.blocks == 0. Ifsp.saidwas tracking somethingsp.blocksdoes not, this could misclassify responses. - Proof: In the removed code (ssepeek_chat_test.go),
opened()returned true when the client held text OR tool calls. The new code only checks blocks. For Anthropic-only streams, this is correct because Anthropic streams always start with a role chunk before content, sosp.blocks > 0implies content was sent. But the change should be verified: does any Anthropic stream path setsp.saidwithout incrementingsp.blocks? - Fix: Verify that for Anthropic streams,
sp.blocks > 0is equivalent to the oldopened()check. If not, restore theopened()method for Anthropic-only use.
- What fails: The condition that determines if a response is buffered changed. The old
-
proxy/proxy.go:1818 — Removed counter for
tooldefer.ClientSearchNamein countLeak- What fails: When a client search call leaks (is handed back to the client), it is no longer counted. The comment says "Counted where it is decided: mixed_searches, or kept for the next request." But if the call leaks due to a failed splice or other error, it should still be counted somewhere.
- Proof: Lines 1818-1821 were removed. The switch now only handles
adjudicate.ToolNameandexpand.ToolName. Iftooldefer.ClientSearchNameappears in thecalledslice passed tocountLeak, it will hit the default case and only be logged, not counted. The old code had a case for it with a comment explaining why it was counted elsewhere. The new code removes that case entirely. - Fix: Either restore the counter for leaked client search calls, or verify that the "counted where it is decided" path covers all leak scenarios. If mixed searches are the only leak case and they are counted elsewhere, document this in a comment.
Non-blocking
- The preset field addition to
/statsis correct and has a test (TestStatsReportsTheRunningPreset). The single-tenant check matches the pipeline field's logic. - The fail-open paths are preserved: buffering a stream instead of splicing it is a degradation, not a failure. The client still gets a complete response.
- The removal of Chat Completions streaming tests is consistent with removing the feature. No orphaned test code remains.
What I checked
- Read CLAUDE.md and docs/design.md for repo rules
- Read the full diff (proxy/proxy.go, proxy/ssepeek.go, proxy/ssepeek_chat_test.go, proxy/stats_golden_test.go, proxy/tooldefer_search_test.go)
- Verified the behavior change: Chat Completions with tool search moves from streamed (spliced) to fully buffered
- Checked that CLAUDE.md requires behavior changes to be disclosed and approved
- Verified the
sp.blocks == 0condition change is correct for Anthropic-only streams - Checked the countLeak function for missing counters
- Verified the preset field addition to
/statshas a test and correct logic - Confirmed fail-open paths are preserved (buffering is a degradation, not a failure)
- Checked that no orphaned test code or references to removed functions remain
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 2ecd56737eb9 |
blocking |
Verdict: blocking
Findings
-
proxy/proxy.go:2171-2179 — Behavior change lacks required human approval documentation
- What fails: Users with deferred tools on Chat Completions lose streaming. The PR removes the streaming splice added in #879 and buffers the entire response instead.
- Proof: Lines 2171-2179 show
isSSE && searchOnnow buffers withio.ReadAll(resp.Body). The comment states "The client loses its stream for the requests of a thread with deferred tools; see #825." This is a behavior change affecting users, but the PR description does not document it per CLAUDE.md requirements. - Fix: Add to PR description: who is affected (Chat Completions users with deferred tools), old behavior (streaming with splice), new behavior (buffered), and how to turn it off (disable tool deferral or use a preset below ultrahigh). Get human developer approval before merge per CLAUDE.md line 44-48.
-
proxy/proxy.go:1748 — Comment claims non-Anthropic dialects are not inspected, but searchOn path inspects them
- What fails: The comment at line 1748 states "Non-Anthropic dialects are not inspected at all" but lines 2171-2179 show Chat Completions streams ARE inspected when
searchOnis true - they are buffered and passed toexpand.AggregateSSE. - Proof: Line 1748 comment vs lines 2171-2179 implementation. The
searchOnpath buffers and processes Chat Completions streams, contradicting the "not inspected at all" claim. - Fix: Update comment to: "Non-Anthropic dialects are not inspected at all, except Chat Completions with our search tool which is buffered (see searchOn path below)."
- What fails: The comment at line 1748 states "Non-Anthropic dialects are not inspected at all" but lines 2171-2179 show Chat Completions streams ARE inspected when
-
proxy/stats_golden_test.go:347-360 — Unrelated preset reporting test in streaming removal PR
- What fails: The test
TestStatsReportsTheRunningPresetand the preset reporting code (proxy.go:2788-2792) appear unrelated to removing Chat Completions streaming. This violates the single-purpose PR principle. - Proof: The test and implementation add preset reporting to
/stats, but the PR is about removing streaming support. No connection is explained. - Fix: Move preset reporting to a separate PR, or explain in the PR description why it belongs with this change.
- What fails: The test
-
proxy/tooldefer_search_test.go — Missing test coverage for buffered searchOn behavior
- What fails: The PR removes 3 streaming tests (TestClientSearchStreamsAndSplicesInBand, TestClientSearchStreamTextPassesThrough, TestClientSearchStreamMixedCall) but adds no tests for the new buffered behavior on the searchOn path.
- Proof: Lines deleted in proxy/tooldefer_search_test.go show streaming tests removed. The remaining tests (TestClientSearchInBand, TestClientSearchMixedCall) test the non-streaming path but do not verify the buffered stream behavior.
- Fix: Add a test that verifies: (1) a Chat Completions stream with searchOn is buffered, (2) the client receives the complete response after the in-band answer, (3) the response is valid JSON (not a partial stream).
Non-blocking
- The
countLeakfunction at proxy.go:1811-1825 no longer needs to handletooldefer.ClientSearchNamesince that case was removed from the switch at line 1820. The default case with the warning will catch it, which is correct behavior. - The preset reporting addition (proxy.go:2788-2792) uses the same single-tenant check as the pipeline reporting above it, which is consistent.
What I checked
- Read CLAUDE.md and docs/design.md for repo rules
- Read the full diff (proxy/proxy.go, proxy/ssepeek.go, proxy/ssepeek_chat_test.go deleted, proxy/tooldefer_search_test.go, proxy/stats_golden_test.go)
- Verified the behavior change: Chat Completions with searchOn now buffers instead of streaming
- Checked that fail-open is maintained: the buffered path still processes responses correctly
- Verified comment accuracy against implementation
- Checked test coverage for the new buffered behavior
- Confirmed the preset reporting addition is unrelated to the main change
The first commit was built from a tree older than #883. It removed the Chat streaming splicer, its tests and a countLeak case. This commit sets every file back to origin/main, so the only proxy changes left are the additive /stats `preset` field, its golden test and the Prometheus exemption. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
R1#1, R1#2, R1#3, R2#1, R2#2 and R2#4 came from an accidental revert of #883. I built the first commit from a tree older than #883. Commit 3dd5dd8 sets every file back to origin/main. Head 82591e9 also merges the current origin/main. The diff against origin/main now has no change in R2#3 (the |
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 82591e9f9b3d |
approve |
Verdict: approve
Status of round 1 findings
All three findings from round 1 are fixed:
-
R1#1 (behavior change disclosure) — Fixed. The accidental revert of #883 removed Chat Completions streaming. Commit 3dd5dd8 restored it. The streaming code is back in proxy/ssepeek.go and proxy/proxy.go.
-
R1#2 (condition change
sp.opened()) — Fixed. Theopened()method is restored at proxy/ssepeek.go:147-153. The condition at proxy/proxy.go:2189 uses!sp.opened()again. -
R1#3 (missing countLeak counter) — Fixed. The
tooldefer.ClientSearchNamecase is restored at proxy/proxy.go:1858-1861 with its original comment.
New commits reviewed
- Commit 3dd5dd8: Restores all files to origin/main, undoing the accidental revert of #883
- Commit 0c0e9ff (merged from origin/main): Adds accountant library integration (#768)
- Commit 82591e9: Merge commit
What changed since round 1
The diff between 2ecd567 (round 1 head) and 82591e9 (round 2 head) shows:
-
Chat Completions streaming restored: proxy/ssepeek.go adds back
newChatSSESplicer(),opened(),rewriteChat(),terminateChat(), andchatProxyToolCallName(). The 308-line test file proxy/ssepeek_chat_test.go is restored. -
Streaming path restored: proxy/proxy.go:2160-2220 restores the splice path for Chat Completions with
searchOn. The buffered-only path is removed. -
countLeak case restored: proxy/proxy.go:1858-1861 restores the
tooldefer.ClientSearchNamecase with its comment. -
Streaming tests restored: proxy/tooldefer_search_test.go adds back the three streaming tests (TestClientSearchStreamsAndSplicesInBand, TestClientSearchStreamTextPassesThrough, TestClientSearchStreamMixedCall).
-
Accountant integration: The merge with origin/main brings in the accountant library changes from #768. This is a separate feature, reviewed and approved in that PR.
-
Preset field remains: The
/statspreset field addition stays. The author states it is needed for #887 part 2 (the status gap). It has a test and is documented in the PR body.
Findings
None. All round 1 findings are fixed.
Non-blocking
- The accountant library integration from the merge is a large change, but it was reviewed in PR #768 and approved there. It is not part of this PR's scope.
- The preset field addition is small, tested, and documented. The author's reason (needed for #887 part 2) is valid.
What I checked
- Last review: round 1, 2ecd567, 2026-11-04T11:06:44Z
- New commits read: 2 (3dd5dd8 "fix(plugin): restore the files #889 reverted by accident", 82591e9 merge with origin/main)
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review: One comment by amiddavid at 2026-11-04T11:33:36Z explaining the accidental revert and the fix
- Verified all round 1 findings are fixed by reading the restored code
- Checked the diff between round 1 head and round 2 head shows the revert is undone
- Verified the Chat Completions streaming code is back (proxy/ssepeek.go, proxy/proxy.go)
- Verified the streaming tests are back (proxy/ssepeek_chat_test.go, proxy/tooldefer_search_test.go)
- Verified the
countLeakcase fortooldefer.ClientSearchNameis restored - Verified the
sp.opened()method is restored and used correctly - Confirmed the preset field addition is the only remaining change from the original PR
- Checked that the accountant library integration is from the merge with origin/main, not this PR
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 82591e9f9b3d |
approve |
Verdict: approve
Findings
None. All round 1 findings are fixed.
Status of round 1 findings
My findings (Reviewer 2, round 1)
-
R2#1 (proxy/proxy.go:2171-2179) — Behavior change lacks required human approval: Fixed. The code that removed streaming for Chat Completions with searchOn is gone. Commit 3dd5dd8 restored proxy/proxy.go to origin/main. The current diff shows Chat Completions with searchOn now uses the splice path (lines 2163-2189), not a buffered path. The behavior change no longer exists.
-
R2#2 (proxy/proxy.go:1748) — Comment claims non-Anthropic dialects are not inspected: Fixed. The comment at line 1785 now correctly states "Of the other dialects, only a Chat Completions stream that declares our own tool search is spliced (#879)." This matches the implementation.
-
R2#3 (proxy/stats_golden_test.go:347-360) — Unrelated preset reporting test: Rejected by author, and I accept the rejection. The author states the preset field is needed for part 2 of #887 (the status gap). The PR body names it under "Additive /stats field". The test at lines 347-360 verifies the field reports the running preset correctly, which is necessary for the plugin to detect restarts. This is not unrelated; it is a prerequisite for #887 part 2.
-
R2#4 (proxy/tooldefer_search_test.go) — Missing test coverage for buffered searchOn behavior: Fixed. The three streaming tests (TestClientSearchStreamsAndSplicesInBand, TestClientSearchStreamTextPassesThrough, TestClientSearchStreamMixedCall) are restored at lines 401-482. They verify the spliced behavior, not a buffered one, which is correct for the current implementation.
Reviewer 1 findings (round 1)
-
R1#1 (PR description) — Missing behavior change disclosure: Fixed. The behavior change (Chat Completions losing streaming) no longer exists. The current implementation splices Chat Completions streams when searchOn is true, preserving streaming.
-
R1#2 (proxy/proxy.go:2133) — Condition change from !sp.opened() to sp.blocks == 0: Fixed. Line 2189 now uses
!sp.opened(), notsp.blocks == 0. The opened() method (ssepeek.go:150-156) correctly checkssp.said || sp.blocks > 0for Chat Completions andsp.blocks > 0for Anthropic. -
R1#3 (proxy/proxy.go:1818) — Removed counter for tooldefer.ClientSearchName: Fixed. Lines 1858-1861 restore the case for tooldefer.ClientSearchName with the comment explaining why it is counted elsewhere.
Non-blocking
- The Chat Completions splice implementation (proxy/ssepeek.go:505-641, proxy/ssepeek_chat_test.go) is comprehensive and correct. It handles: text streaming, call detection, index renumbering across rounds, mixed responses, truncation, and gateways that omit [DONE].
- The preset field addition to /stats (proxy/proxy.go:2788-2792, proxy/stats_golden_test.go:347-360) is correct and necessary for #887 part 2.
- Fail-open is preserved: the splice degrades to a hand-back when the retain bound is exceeded or a rebuild fails, and the client still gets a complete response.
What I checked
- Last review: round 1, 2ecd567, 2026-11-04T11:09:30Z
- New commits read: 2 (3dd5dd8 "fix(plugin): restore the files #889 reverted by accident", 82591e9 "merge origin/main")
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Read the full diff from 2ecd567..HEAD (git diff output, 8448 insertions, 929 deletions)
- Verified each round 1 finding is fixed:
- R2#1: proxy/proxy.go lines 2163-2189 show Chat Completions with searchOn now uses the splice path, not buffered
- R2#2: proxy/proxy.go line 1785 comment is correct
- R2#3: author's rejection is valid; preset field is necessary for #887 part 2
- R2#4: proxy/tooldefer_search_test.go lines 401-482 restore the three streaming tests
- R1#1: behavior change no longer exists
- R1#2: proxy/proxy.go line 2189 uses !sp.opened(); ssepeek.go lines 150-156 implement opened() correctly
- R1#3: proxy/proxy.go lines 1858-1861 restore the tooldefer.ClientSearchName case
- Read proxy/ssepeek.go lines 500-641 (Chat Completions splice implementation)
- Read proxy/ssepeek_chat_test.go lines 1-100 (test coverage for Chat Completions splice)
- Verified the preset field implementation (proxy/proxy.go:2788-2792) and its test (proxy/stats_golden_test.go:347-360)
- Confirmed fail-open paths are preserved in the splice implementation
…0.2.11) (#921) Claude Code plugin 0.6.6 -> 0.6.7: - #889: the preset picker restarts the proxy after a yes, and the status shows a pending preset. - #891: insights and the status show tool deferral as its own saving lever. - #877, #885: save-more tools (keep, unkeep, defer, undefer, search on/off, revert). - #882: ultrahigh is marked experimental in the picker. Codex plugin 0.2.10 -> 0.2.11: - #889, #891: the same cg.py changes (vendored copy). - #882: ultrahigh is marked experimental in the picker. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Behavior change (needs a human developer's yes)
/context-guru:preset-picker.ultrahighprobe to that old proxy.preset restartrestarts the proxy. It sends theultrahighprobe to the restarted proxy only. The status screen and status line showpreset: xhigh (ultrahigh after a restart)while the two differ.Summary
preset setreads the running preset from/statsand printsrunning=,restart_needed=andgap=.preset restart --name Xrunsstart-proxy.sh, the same path a session start uses:strategy sync, fingerprint compare, stop by pidfile, start. It does not kill by pattern. It then checks/stats.cg.py home(/context-guru:status) and the status line show the gap.Additive /stats field
/statsgains apresetkey (the preset the proxy started with, single-tenant only, likepipeline).Owner decisions
preset restartleaves it alone and reportsnot_applied.Data dependence
None. Nothing new is stored. No row in
docs/data-dependence.mdchanges.What changed
context-guru-plugin/scripts/settings.py:saved_preset,running_preset,preset_gap_note,preset restart. No probe goes to a stale proxy.context-guru-plugin/scripts/statusline.py: newpresetelement, shown only on a gap, in every layout.context-guru-plugin/scripts/cg.py(and the Codex copy): a gap line on the home screen.preset-pickerandstatustext.metrics/metrics.go,proxy/proxy.go: thepresetfield.How it was tested
On box 2, with
-race:go test -race ./context-guru-plugin/passes (364 s).go test -race ./proxy/... ./metrics/... ./cmd/...passes, after the Prometheus exempt entry forPreset.restart_needed=trueand no probe; matching proxy gives the probe;preset restartreplaces the proxy throughstart-proxy.shand the probe reaches the restarted one; unrouted directory refuses; status line shows the gap and stays quiet when equal or unknown;/statsreports the preset.preset setmadeTestPresetSetWithAStaleProxyAsksForARestartAndSendsNoProbefail. Restored.Technical notes
preset restartpasses--unrouted --no-update-check --port --preset(and the configuredupstreamandidle_exit) tostart-proxy.sh, because plugin options do not reach a Bash call./statsstill shows the old preset and the result isnot_applied.preset. The gap stays hidden then, not guessed.🤖 Generated with Claude Code