Repository navigation
Answer background AI requests with sonnet and thinking off - #330
Merged
Merged
Conversation
Print mode thinks by default, so a short JSON answer cost a median 2,656 output tokens: context labels took a median 28 s and 43 of 252 missed the 60 s deadline. A claude model turn now runs with MAX_THINKING_TOKENS=0 and the default model is sonnet, which answered the same prompt in 3.6-7 s.
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…four hided flakes (#1860) Closes with-hide/hide-private#351 Closes with-hide/hide-private#321 Closes with-hide/hide-private#347 Closes with-hide/hide-private#330 Related: with-hide/hide-private#339 (diagnostics only; the issue stays open) ## Summary Five flaky hided tests, one cause each: - #351 (`link_mux` connection end): on macOS a `recv` blocked on a local socket sometimes misses its peer's shutdown, and after that misses its own end's shutdown too. Then a core-side mux never saw its node end and kept its streams. Every macOS `LocalStream` read now waits in `poll` first, which hears both. The test's own `SO_RCVTIMEO` (EINVAL on macOS after the end) is replaced by a reading thread with a hang guard. - #321 (`device_bootstrap`): five tests each copied and stripped the 140 MB debug `hided` at once, past the fixture's 10 s command bound. A shared helper now strips and signs each build version once under a lock, and `remote_delivery` and `core_move` use it too. - #347: its one flaky run was the CI merge commit 15f05b4 of a #1846 head that was later rewritten, where 43 of 44 `core_move` tests failed together. It has passed first try on main since. The cause of that run is not proven; the issue is closed on the later main passes (evidence in the issue comment). - #330: the test was deleted with the SFTP upload in 14b6b68. - #339 (WSL, Windows only): the cause is not found. The journey keeps its steps and the Hide AI progress in a bounded in-memory record (256 lines) and prints it only when it fails. At its own 105 s guard, before the lane's 120 s one, it prints the record and the distribution's processes, read by an owned `ps` bounded to 10 s, and ends the test. A passing run prints nothing. ## Review - **판단해 주세요**: a macOS-only `poll` before every local-socket read, against the kernel's lost wakeup, instead of changing each caller that waits for a peer's end. - **조심해서 볼 파일**: `hide-platform/src/ipc.rs` - high-frequency path: every `LocalStream` read on macOS (Herdr socket, mux, pane service). - **조심해서 볼 파일**: `hided/tests/it/support/shipped.rs` - shared state across test processes: lock, half-made copy cleanup, eviction of an older build. - **질문**: `link_mux`'s end tells the link's user by shutting down its end of an in-process pair, which a Windows peer does not hear until the handle closes, and no `link_mux` test runs on Windows. Should that become its own issue? - **비용 검토**: one `poll(2)` per macOS read, with no new thread, timer, queue or notification. Linux and Windows read paths are unchanged (`cfg!(target_vendor = "apple")`). The mux frame reader sits behind a `BufReader`, so a frame is not one read per field. ## Evidence - **확인한 것**: #351 reproduced before the fix: `the_connection_ending_frees_every_stream` failed in 1 of 13, 1 of 81 and 1 of 141 stress iterations (both signatures). A stack sample showed the core's demux thread asleep in `recvfrom` after its peer ended. - **확인한 것**: the kernel behaviour, in C at load ~30 on macOS 15.1: `recv` after the peer's `shutdown(SHUT_WR)` hung for over 60 s, about once in 4,500 rounds. A `poll` wait hung 0 times in 48,000 rounds, and `close()` 0 times in 18,000. - **확인한 것**: the new contract test `a_shutdown_ends_the_peers_blocked_read_every_time` hung in recvfrom on its first iteration before the fix. Its rounds now run in an owned exact-test subprocess bounded to 60 s. With the macOS `poll` removed again, it failed at stress iteration 12 (round 3,724) in 10 s, with the subprocess reaped. With the fix: 75 runs × 5,000 rounds passed, and the `link_mux` tests passed 300 of 300 stress iterations (before the drain's failure-path change, which only touches a timeout). - **확인한 것**: `device_bootstrap` passed 6 of 6 twice locally at 8 threads (macOS, private sshd and pinned Herdr 0.9.5). The store held one stripped copy, rebuilt once when the build changed. - **확인한 것**: `hide-platform` + `hided` (lib and `it`) 971 tests and `herdr-core` + `hide-herdr-client` 3,496 tests passed on macOS with the change. Clippy `-D warnings` and fmt are clean. - **확인한 것**: the new contract is Unix only: on the first CI run, `os contract (windows)` showed that a Windows shutdown never reaches the peer (`CancelIoEx` ends this end's own I/O; the peer hears the end when the handle closes). - **확인하지 못한 것**: #339's cause (no WSL here). `wsl_device.rs` is Windows-only; a cross-check from macOS could not build its C dependencies, so the `windows wsl` lane is its first compile. - **확인한 것 (비용, 미시)**: a C microbenchmark of plain `recv` vs `poll`+`recv` on one socketpair (macOS 15.1, load 18-48), not a product build. 64 B messages × 300,000: `recv` 1.14-5.87 µs per read over 5 completed trials, `poll`+`recv` 1.61-6.71 µs over 9. The difference within a matched pair was 0.3-1 µs; 2 more `recv` trials hung on the lost wakeup. 16 KiB × 20,000, 6 trials each: 5.7-17.8 µs vs 6.4-16.4 µs, with the pairs disagreeing in sign (noise). - **확인하지 못한 것 (비용, 실사용)**: `docs/PERFORMANCE_TESTING.md`'s matched idle/driven terminal measurement (`scripts/web-shell-measure`, `MEASURE_SCENARIO=keys`: key echo p50/p95, hided CPU and RSS, base a891332 vs this head). It was not run: two release builds do not fit on this Mac's disk now, and its load is 20-60. The microbenchmark does not prove the product's end-to-end cost. - **확인하지 못한 것**: `core_move` and `remote_delivery` with the shared helper (left to the remote mailbox lane). <details><summary>Verification record</summary> </details>
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
백그라운드 AI(에이전트 라벨, Project Memory, worktree 이름)가 느리던 원인은 Claude CLI print mode가 기본으로 생각(thinking)을 켜는 것이었습니다.
약 100토큰짜리 JSON 답에 출력 토큰을 중간값 2,656개(최대 9,425개) 썼고, 라벨은 중간값 28초, 252회 중 43회가 60초 deadline을 넘겼습니다.
이제 claude 모델 호출은
MAX_THINKING_TOKENS=0으로 돌고, 기본 모델은sonnet입니다.Review
/usage)으로는 재지 않았습니다.hide-ai/src/claude.rs- 모델 호출 child의 환경에 변수를 하나 더합니다. 로그인 probe(Inherit)와/usage(화이트리스트)는 그대로입니다.Evidence
bash scripts/verify-cargo.sh test -p hide-ai전체 통과, 새 테스트a_model_turn_runs_with_thinking_off_whatever_the_shell_exports는 부모 셸이MAX_THINKING_TOKENS=31999를 내보내도 child가0을 받는지 봅니다.bash scripts/verify-cargo.sh lint통과.claude -p에 직접 넣어 쟀습니다.--settings '{"alwaysThinkingEnabled":false}'는 생각을 끄지 못했고(출력 2,380토큰), 환경 변수만 껐습니다.gpt-5.6-luna기본 강도(medium)가 6~8초, low가 6초 안팎이라 손볼 이유가 없었습니다.Breaking change
이미 Settings › Background AI에서 무언가를 고른 적이 있으면
ai.json에 claude 모델이haiku로 적혀 있어 haiku가 유지됩니다.sonnet으로 바꾸려면 Settings에서 claude 모델을 sonnet으로 고르면 됩니다. 생각 끄기는 모델과 상관없이 바로 적용됩니다.