Repository navigation
Conversation
Member
|
Thanks @tianmind-studio — this is a clean, well-scoped fix for the #8906 regression. What I like:
Two non-blocking observations for a maintainer:
No security or supply-chain concerns on my read. Flagging for maintainer review because this touches the provider/model proxy surface and the timeout value is a prod tuning decision. |
kodjima33
approved these changes
Jul 3, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Desktop bug fix (owner-override): improve Gemini proxy timeout observability/handling in local Rust proxy. Small, CI-green.
This was referenced Jul 3, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Jul 3, 2026
Closes #8950. ## Summary - fix Gemini realtime ephemeral token minting by sending Google Live API's documented `authToken` request wrapper instead of top-level token fields - move benign long-lived realtime idle teardown out of the failure-like `realtime_provider_session_error` bucket into `realtime_provider_expected_idle_teardown` - add stable realtime diagnostics dimensions for auth mode, failure class, HTTP status, and barge-in replacement mint failures so the daily health report can separate actual provider/session failures from lifecycle noise - add focused Swift and Rust regression coverage plus a desktop changelog fragment ## Recently merged coverage - #8911 already addressed part of the broader July 3 Gemini picture by improving non-streaming Gemini proxy timeout observability and retryable timeout behavior. - That did not cover this issue's realtime health stream or `/v2/realtime/session` Gemini ephemeral-token mint path, which are fixed here. ## Root cause The Gemini realtime mint route posted `uses`, `expireTime`, and `newSessionExpireTime` at the top level. Google's current Live API `CreateAuthTokenRequest` requires those settings under `authToken`, so managed Gemini realtime users could fail before opening the provider session. Separately, expected Gemini idle closes were correctly classified locally but still emitted into the failure-like health event stream. ## Testing - `git diff --check` - `cargo test --manifest-path desktop/macos/Backend-Rust/Cargo.toml gemini_auth_token_body_wraps_settings_under_auth_token` - `xcrun swift test --package-path desktop/macos/Desktop --filter 'DesktopDiagnosticsManagerTests|RealtimeHubCloseClassifierTests'` - `scripts/pre-push` <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/8953?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
kodjima33
added a commit
that referenced
this pull request
Jul 12, 2026
… (#9583) Fixes #9135. ## Bug (live on prod) The desktop Gemini proxy returns persistent `504`s on `/v1/proxy/gemini/models/gemini-2.5-flash:generateContent` while `/health` stays green. ## Root cause **The proxy — not the upstream — was the binding deadline.** `GEMINI_UPSTREAM_TIMEOUT` was hardcoded to 90s, with the comment "keep non-streaming upstream calls below observed Cloud Run request boundaries". But `desktop-backend`'s Cloud Run request timeout is actually **300s** (`gcloud run services describe desktop-backend --format='value(spec.template.spec.timeoutSeconds)'` → `300`), and the Swift client waits **300s** (`GeminiClient.swift`) and deliberately does not auto-retry timeouts. So the 90s guess was ~3.3x tighter than the real bound, and it aborted generations the model had already spent the money to produce. ## Prod evidence (last 6h, `desktop-backend` Cloud Logging) - **11 of 1000** `/v1/proxy/gemini` unary calls returned `504` (~1.1%). - **Every** `504` had latency **90.03–90.13s** — our own timeout firing, not an upstream failure. - All were `phase=request status=timeout provider=vertex_ai model=gemini-2.5-flash`, `payload_bucket` 16–512kb. - Successful calls reach **84.5s**, and 6 completed in the `60-120s` bucket — the latency tail straddles the cap, so the cap was slicing through live traffic. ## Upstream premise verified against real prod Vertex AI Long-context 2.5-flash spends most of its wall-clock *thinking*, before the first response byte: | request | result | |---|---| | 181 KB / 40k prompt tokens | `200` in **64.3s** (7,863 thinking tokens) | | 741 KB / 150k prompt tokens | `200` in **95.5s**, full valid answer | The second one **would have been 504'd at 90s** — a successful generation thrown away, and the user shown "AI request took too long". ## Fix Derive the deadline from the platform bound instead of hardcoding a guess: ```rust const CLOUD_RUN_REQUEST_TIMEOUT: Duration = Duration::from_secs(300); const GEMINI_UPSTREAM_HEADROOM_SECS: u64 = 60; const GEMINI_UPSTREAM_TIMEOUT: Duration = Duration::from_secs(CLOUD_RUN_REQUEST_TIMEOUT.as_secs() - GEMINI_UPSTREAM_HEADROOM_SECS); // 240s ``` This closes the failure class rather than re-tuning a number: the deadline can no longer drift above the platform timeout, so the proxy always remains the component that gives up first and clients keep getting our typed, retryable `upstream_timeout` JSON instead of an opaque platform 504. Streaming is untouched (it correctly has no total-response timeout). Error classification, structured `upstream_result` logging, and the typed 504 body already landed in #8911 — this fixes the remaining defect: the deadline itself. ## Regression test The existing test hardcoded the very bound that was wrong (`GEMINI_UPSTREAM_TIMEOUT <= 90s`), so it would have *locked the bug in*. It now asserts the real contract: strictly below the platform timeout, ≥30s flush headroom, and generous enough to cover the observed completion tail. ## Verification - `cargo test proxy::` → **78 passed**, 0 failed - `cargo clippy` → clean (no warnings) - `cargo check` → clean - Prod log analysis + real prod Vertex timing runs above **Not exercised:** an authenticated >90s request through the running proxy — that needs a signed-in desktop session and Omi Dev is not signed in on this machine. The upstream premise and the constant contract are proven; the passthrough itself is not path-exercised. 🤖 automated by hourly watchdog <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9583?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Git-on-my-level
added a commit
that referenced
this pull request
Jul 13, 2026
## Summary - replace the permanently cached Redis connection with a generation-aware, single-flight recovery owner - classify Redis failures, retry safe commands once, and never replay outcome-ambiguous metering scripts - fail managed Gemini/chat/TTS requests closed when Redis metering is unavailable while preserving BYOK bypasses - expose Redis dependency state at `/ready` without removing Redis-independent traffic from Kubernetes service readiness - give non-streaming Gemini work one 75-second end-to-end budget, propagate downstream cancellation, preserve request correlation, and emit bounded phase-owned outcomes Addresses #9524. ## Root cause and recurrence The Rust backend cached one multiplexed Redis connection for the process lifetime. A broken pipe was returned to the caller, but no owner invalidated that connection, so every later metered request reused the stale generation until process restart. The same owner also allowed concurrent cold-start connections. The Gemini timeout class recurred after #8640 and #8911 because those fixes only moved a per-attempt timeout to the current infrastructure boundary. Token acquisition, provider fallback, dispatch, and body drain did not share one logical deadline, and timeout outcomes were not separated from auth or generic provider failures. ## Durable guard - Redis leases carry generation and age; stale failures conditionally invalidate only their own generation. - Connection creation is single-flight with bounded connect/command deadlines, per-instance jitter, and cooldown after exhaustion. - Transport failures reconnect; auth/config, capacity, and command/data errors do not masquerade as stale transport. - Reads and idempotent final-state writes replay at most once. Rate-limit Lua scripts and task acceptance never replay after an outcome-unknown transport failure. - Redis operation telemetry has bounded operation/failure/reconnect fields and production-visible success denominators. - Managed-key metering fails closed with retryable 503 responses; BYOK remains Redis-independent. - Gemini uses one logical deadline below the observed 90-second boundary. Auth timeout, provider timeout, 429, provider 5xx, transport failure, and cancellation are distinct bounded outcomes; provider/mode changes use the shared fallback event. - Request IDs are returned on proxy-owned provider errors and logged without prompts, bodies, keys, or user content. ## Verification - `cd desktop/macos && bash test.sh` — launcher checks passed, Rust suite passed, and 237 Swift suites passed in isolation - `cd desktop/macos/Backend-Rust && cargo test --locked` — 346 passed - `cd desktop/macos/Backend-Rust && cargo check --locked` — passed - `cd desktop/macos/Backend-Rust && cargo fmt -- --check` — passed - `make preflight` — all 9 selected manifest checks passed; no locked product invariants apply - independent agent review — approved with no remaining blocker The fault tests exercise the production Redis client against scripted RESP sockets: first-command connection close, safe replay recovery, non-replayable EVAL, eight concurrent stale callers, reconnect exhaustion, repeated stale generations, and auth/config rejection. Gemini tests exercise a hanging local upstream plus a real Axum HTTP downstream disconnect, proving the upstream request is dropped without detached work. ## Rollout notes No production mutation is included in this PR. After deployment, verify the exact revision with a controlled Redis connection close, authenticated managed-key TTS, and a natural-traffic window longer than the prior short soak. Roll back on retry amplification, duplicate metering, or a new TTS failure cluster. The repository does not own the external release-health dashboard/alert consumer. This PR supplies bounded `gemini_provider_request` outcomes so #9523 can exclude provider timeouts from release-regression aggregation while continuing to report the provider SLO separately. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9533?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This was referenced Jul 15, 2026
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 23, 2026
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 23, 2026
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 23, 2026
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 23, 2026
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 24, 2026
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 24, 2026
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 24, 2026
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 24, 2026
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 26, 2026
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 26, 2026
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
kodjima33
pushed a commit
that referenced
this pull request
Jul 28, 2026
…10054) * fix(chat): consume one request deadline budget on the Anthropic path The provider-timeout class (FC-per-hop-timeout: #8640, #8911, #9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes #9835. Co-Authored-By: Claude Fable 5 <[email protected]> * harden(ci): reject chat provider sends that bypass send_with_deadline Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: #8640/#8911/#9135/#9644 (#9835). Co-Authored-By: Claude Fable 5 <[email protected]> * fix(chat): count reasoning deltas as semantic progress ThinkingDelta chunks reach the client as `reasoning_content`, but they did not refresh the semantic idle timer — only text deltas did. So after the initial role chunk, a Claude reasoning phase that kept emitting visible reasoning for longer than STREAM_IDLE_TIMEOUT was ended as "no semantic progress" while the client was actively receiving output, regressing the "a long visible stream is not an error" contract (#9135) for reasoning streams. Refresh the timer when a reasoning chunk is yielded, matching the text-delta path. Regression test drives a reasoning-only stream 200s past the 60s idle bound on the paused clock: it fails on the old code (1 of 4 reasoning deltas delivered, turn killed at the bound) and passes with the fix. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(chat): register deadline guard artifact Failure-Class: FC-per-hop-timeout --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Max Carter 祁明思 <[email protected]>
undivisible
added a commit
to Archit-lal/omi
that referenced
this pull request
Jul 29, 2026
…asedHardware#10054) * fix(chat): consume one request deadline budget on the Anthropic path The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]> * harden(ci): reject chat provider sends that bypass send_with_deadline Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]> * fix(chat): count reasoning deltas as semantic progress ThinkingDelta chunks reach the client as `reasoning_content`, but they did not refresh the semantic idle timer — only text deltas did. So after the initial role chunk, a Claude reasoning phase that kept emitting visible reasoning for longer than STREAM_IDLE_TIMEOUT was ended as "no semantic progress" while the client was actively receiving output, regressing the "a long visible stream is not an error" contract (BasedHardware#9135) for reasoning streams. Refresh the timer when a reasoning chunk is yielded, matching the text-delta path. Regression test drives a reasoning-only stream 200s past the 60s idle bound on the paused clock: it fails on the old code (1 of 4 reasoning deltas delivered, turn killed at the bound) and passes with the fix. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(chat): register deadline guard artifact Failure-Class: FC-per-hop-timeout --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Max Carter 祁明思 <[email protected]>
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.
Fixes #8906.
Summary
upstream_resultshape as successful upstream responses, including provider/model/action/payload bucket/duration bucket/phase/statusTesting
git diff --checkdesktop/macos/changelog/unreleased/20260703-gemini-proxy-timeout.jsonPRE_PUSH_SKIP_DESKTOP_RUST=1 scripts/pre-push-> passed non-Rust gates; desktop changelog fragment foundNote
This Windows machine does not have
cargo/rustfmtinstalled, so I could not run the local desktop Rust checks. The GitHubLint & Format Checkdesktop Rust job should runrustfmt --checkandcargo check --lockedfor this PR.