Fix supervisor AI empty replies with fallback templates
Skip appending AI error strings to the session and use event-specific fallback commentary when the model returns empty content. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -136,3 +136,25 @@ def test_normalize_supervisor_settings_env(monkeypatch):
|
||||
cfg = sup.normalize_supervisor_settings({})
|
||||
assert cfg["wechat_webhook"] == "https://example.com/hook"
|
||||
assert cfg["wechat_link_base"] == "https://hub.example/ai?mode=supervisor"
|
||||
|
||||
|
||||
def test_supervisor_fallback_reply_program_sl():
|
||||
text = sup.build_supervisor_fallback_reply(
|
||||
{
|
||||
"event_type": sup.EVENT_PROGRAM_SL,
|
||||
"symbol": "ZEC/USDT",
|
||||
"pnl_amount": -0.9557,
|
||||
}
|
||||
)
|
||||
assert "程序止损" in text
|
||||
assert "AI 生成失败" not in text
|
||||
|
||||
|
||||
def test_supervisor_fallback_not_error_reply():
|
||||
from hub_ai.text_util import is_ai_error_reply
|
||||
|
||||
text = sup.build_supervisor_fallback_reply(
|
||||
{"event_type": sup.EVENT_MANUAL_CLOSE, "symbol": "ETH/USDT", "pnl_amount": -1}
|
||||
)
|
||||
assert text
|
||||
assert not is_ai_error_reply(text)
|
||||
|
||||
Reference in New Issue
Block a user