feat(client): ProxyConfig.request_timeout_seconds (default 35s, reject <=0)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,8 +7,19 @@ extends RefCounted
|
||||
const SETTING := "coc_rpg/proxy_base_url"
|
||||
const DEFAULT := "http://localhost:8000"
|
||||
|
||||
const TIMEOUT_SETTING := "coc_rpg/proxy_request_timeout_seconds"
|
||||
const TIMEOUT_DEFAULT := 35.0
|
||||
|
||||
|
||||
static func base_url() -> String:
|
||||
var v = ProjectSettings.get_setting(SETTING, DEFAULT)
|
||||
var s := str(v)
|
||||
return s if s != "" else DEFAULT
|
||||
|
||||
|
||||
static func request_timeout_seconds() -> float:
|
||||
# Just above the server's OLLAMA_TIMEOUT_SECONDS (30) so a slow model surfaces
|
||||
# the server's own error first, while a fully-hung proxy is still bounded. A
|
||||
# non-positive value would re-enable the infinite hang, so reject it.
|
||||
var v := float(ProjectSettings.get_setting(TIMEOUT_SETTING, TIMEOUT_DEFAULT))
|
||||
return v if v > 0.0 else TIMEOUT_DEFAULT
|
||||
|
||||
@@ -62,3 +62,19 @@ func test_npc_result_fallback_is_degraded_with_no_moves():
|
||||
assert_eq(r.valid_moves, [])
|
||||
assert_eq(r.facts, [])
|
||||
assert_false(r.ends_conversation)
|
||||
|
||||
|
||||
func test_request_timeout_default():
|
||||
if ProjectSettings.has_setting(ProxyConfig.TIMEOUT_SETTING):
|
||||
ProjectSettings.clear(ProxyConfig.TIMEOUT_SETTING)
|
||||
assert_eq(ProxyConfig.request_timeout_seconds(), ProxyConfig.TIMEOUT_DEFAULT)
|
||||
|
||||
|
||||
func test_request_timeout_override_and_reject_nonpositive():
|
||||
var ProxyConfig = preload("res://scripts/net/proxy_config.gd")
|
||||
ProjectSettings.set_setting(ProxyConfig.TIMEOUT_SETTING, 12.5)
|
||||
assert_eq(ProxyConfig.request_timeout_seconds(), 12.5)
|
||||
# A non-positive override must NOT re-enable the hang — falls back to default.
|
||||
ProjectSettings.set_setting(ProxyConfig.TIMEOUT_SETTING, 0.0)
|
||||
assert_eq(ProxyConfig.request_timeout_seconds(), ProxyConfig.TIMEOUT_DEFAULT)
|
||||
ProjectSettings.clear(ProxyConfig.TIMEOUT_SETTING)
|
||||
|
||||
Reference in New Issue
Block a user