feat(chat): make streaming and chat timeouts per-profile configurable
The chat request previously used a hard-coded 30 s timeout and ignored --read-timeout entirely (that flag only bounded URL prompt fetching), so slow reasoning models were cut off mid-generation unless one remembered to pass --stream (which used a separate hard-coded 600 s). Resolve `stream`, `read_timeout` and `connect_timeout` from [default]/[model.<profile>] into PromptConfig and wire the (connect, read) timeout into both the streaming and non-streaming chat calls. CLI --stream/--read-timeout/--connect-timeout still override; the two timeout flags default to None so a config value can win, with the URL-fetch fallbacks (3 s/10 s) preserved. Default chat read_timeout is now 600 s. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
e2297f43e4
commit
6076e3bcb8
9 changed files with 91 additions and 10 deletions
|
|
@ -258,3 +258,33 @@ def test_chat_params_cli_overrides_config(tmp_path):
|
|||
_, prompt_cfg = resolve_effective_config(args)
|
||||
assert prompt_cfg.max_tokens == 512
|
||||
assert prompt_cfg.temperature == 0.1
|
||||
|
||||
|
||||
def test_stream_and_timeouts_default(tmp_path):
|
||||
cfg_path = _write_config(tmp_path)
|
||||
_, prompt_cfg = resolve_effective_config(_parse(["--start", "--config", str(cfg_path)]))
|
||||
assert prompt_cfg.stream is False
|
||||
assert prompt_cfg.read_timeout == 600.0 # generous default for reasoning models
|
||||
assert prompt_cfg.connect_timeout == 10.0
|
||||
|
||||
|
||||
def test_stream_and_read_timeout_from_config(tmp_path):
|
||||
cfg = CONFIG_BASIC.replace(
|
||||
"poll_interval = 2",
|
||||
"poll_interval = 2\nstream = true\nread_timeout = 900\nconnect_timeout = 5",
|
||||
)
|
||||
cfg_path = _write_config(tmp_path, cfg)
|
||||
_, prompt_cfg = resolve_effective_config(_parse(["--start", "--config", str(cfg_path)]))
|
||||
assert prompt_cfg.stream is True
|
||||
assert prompt_cfg.read_timeout == 900.0
|
||||
assert prompt_cfg.connect_timeout == 5.0
|
||||
|
||||
|
||||
def test_stream_and_read_timeout_cli_overrides_config(tmp_path):
|
||||
cfg = CONFIG_BASIC.replace("poll_interval = 2", "poll_interval = 2\nread_timeout = 900")
|
||||
cfg_path = _write_config(tmp_path, cfg)
|
||||
# --stream forces streaming on; --read-timeout overrides the config value.
|
||||
args = _parse(["--chat", "-p", "hi", "--config", str(cfg_path), "--stream", "--read-timeout", "42"])
|
||||
_, prompt_cfg = resolve_effective_config(args)
|
||||
assert prompt_cfg.stream is True
|
||||
assert prompt_cfg.read_timeout == 42.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue