Reconnect idle Cloud conversations after transient stream loss (#60969)

## Why

A lost Cloud reply stream previously required reopening the conversation, even when it was idle. Recover the displayed conversation automatically while holding queued input until its reply stream is usable.

## What changed

- Add bounded retries for transient stream failures in the displayed, idle conversation, with credential and network-policy checks. Keep explicit reopen behavior when recovery is unavailable or fails.
- Enable HTTP/2 keepalive pings for Cloud connections.
- Queue input while disconnected and resume ordinary submission after recovery. Mark recovered history as potentially incomplete so an explicit reopen reloads missed turns while preserving drafts and reconciling pending submissions.
- Store retained input per backend and apply background settings updates to the owning backend's drafts.

## Testing

Add regression coverage for queued input during disconnection and extend resume and backend-handoff tests to cover history refresh, draft preservation, and retained settings.

GitOrigin-RevId: 3d753e53d3c0d594680a90cac8a75fe33b91e219
This commit is contained in:
Benjamin Carlsson
2026-11-12 01:57:33 +00:00
committed by copyberry
parent 5c3ff1dabf
commit f988ada4bf
34 changed files with 777 additions and 108 deletions
+3
View File
@@ -104,6 +104,8 @@ use tower::util::BoxCloneSyncService;
use url::Url;
const REQUEST_TIMEOUT: Duration = Duration::from_secs(150);
const HTTP2_KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(10);
const HTTP2_KEEP_ALIVE_TIMEOUT: Duration = Duration::from_secs(60);
const MAX_MESSAGE_BYTES: usize = 64 * 1024 * 1024;
const MODEL_CATALOG_TIMEOUT: Duration = Duration::from_secs(10);
const MAX_MODEL_CATALOG_BYTES: usize = 1024 * 1024;
@@ -179,6 +181,7 @@ impl Client {
.without_redirects()
.without_request_logging()
.http2_prior_knowledge()
.http2_keep_alive(HTTP2_KEEP_ALIVE_INTERVAL, HTTP2_KEEP_ALIVE_TIMEOUT)
.connect_timeout(Duration::from_secs(30));
let http = if local_http {
// Plaintext credentials must never leave loopback through an outbound proxy.