fix(delegate): keep finite stale-timeout for loopback proxy; interrupt idle-stale children - #1
Open
neaucode-bot wants to merge 1 commit into
Conversation
…t idle-stale children The stream stale-timeout (and matching httpx read-timeout) was disabled for any loopback base_url. That misclassifies the cursor-openai-api proxy — a loopback transport fronting a remote backend — as a slow local model server and removes the only fast stream-recovery path, so an upstream stall becomes an indefinite silent hang. Detect a *real* local engine via a cached detect_local_server_type probe (gated behind the cheap is_local_endpoint pre-check so remote URLs are never probed) instead of trusting the raw loopback address. The proxy now keeps a finite, context-scaled stale timeout; the large-context ceiling is raised to 900s so a legitimate multi-minute prefill survives. Explicit HERMES_STREAM_STALE_TIMEOUT / HERMES_STREAM_READ_TIMEOUT overrides still win. Also interrupt an idle-stale delegate child (not mid-tool) instead of only stopping the heartbeat, so a live session recovers without waiting on the gateway drain. Adds tests for the cached probe, the real production gate, and the idle-vs-in-tool interrupt behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Hardens delegation against the silent multi-minute "stuck subagent" hang (root cause behind a ~10 min client-visible freeze where a healthy 589s / 4.5M-token opus delegate looked dead).
base_url, which treats thecursor-openai-apiproxy (loopback transport fronting a remote backend) as a slow local model server and removes the only fast stream-recovery path. Now we detect a real local engine via a cacheddetect_local_server_typeprobe (gated behind the cheapis_local_endpointpre-check so remote URLs are never probed); the proxy keeps a finite, context-scaled stale timeout.HERMES_STREAM_STALE_TIMEOUT/HERMES_STREAM_READ_TIMEOUToverrides still win.Why stacked on
fix/delegate-task-model-forwardingThis builds on the delegation work in NousResearch#48867 and is scoped as a separate, reviewable change. Base it on
mainonce NousResearch#48867 merges, or merge in order.Test plan
tests/agent/test_proxy_stale_timeout.py(cached probe + real production gate: loopback proxy stays finite, detected engine disables, remote never probed, api_key forwarded)tests/tools/test_heartbeat_stale_interrupt.py(idle-stale child interrupted; in-tool child not interrupted)test_delegate,test_model_metadata,test_stream_read_timeout_floor,test_non_stream_stale_timeout(300 passed)Made with Cursor