Add multi-turn Assistent session diagnostics to the Debug API.
POST /assistent/session + /chat with rich per-turn traces (patch, Exact merge, compact_context); chat-eval wraps one session turn. Docs playbook and unit/HTTP tests included. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-3
@@ -193,24 +193,41 @@ def test_extract_assistent_patch():
|
||||
|
||||
def test_chat_eval_mocked_http(monkeypatch, tmp_path):
|
||||
from gpu_rent import debug_assistent
|
||||
from gpu_rent import debug_assistent_session as das
|
||||
|
||||
_auth_env(monkeypatch, tmp_path)
|
||||
cfg = load_config(require_auth=True)
|
||||
das.reset_session_store_for_tests()
|
||||
|
||||
monkeypatch.setattr(
|
||||
debug_assistent,
|
||||
das,
|
||||
"_swarm_base",
|
||||
lambda cfg: ("http://127.0.0.1:17801", "local"),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
debug_assistent,
|
||||
das,
|
||||
"_session_id",
|
||||
lambda base: ("sess-1", None, 5.0),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
das,
|
||||
"_resolve_chat_model",
|
||||
lambda cfg, base, sid, model=None: ("qwen3-vl:8b", "qwen3-vl:8b"),
|
||||
)
|
||||
|
||||
calls: list[tuple[str, dict]] = []
|
||||
|
||||
def fake_http(url, *, method="GET", body=None, timeout=12.0):
|
||||
if url.endswith("/API/AssistentGetConfig"):
|
||||
return True, {
|
||||
"success": True,
|
||||
"persona": "leonid",
|
||||
"exact": {
|
||||
"profiles": {"turbo": {"steps": 8, "cfg": 1, "sigma_shift": 1.15}}
|
||||
},
|
||||
"skills": [],
|
||||
"enabled_skills": [],
|
||||
}, 8.0
|
||||
if url.endswith("/API/AssistentListModels"):
|
||||
return True, {"preferred": "qwen3-vl:8b", "models": ["qwen3-vl:8b"]}, 10.0
|
||||
if url.endswith("/API/AssistentChat"):
|
||||
@@ -223,7 +240,7 @@ def test_chat_eval_mocked_http(monkeypatch, tmp_path):
|
||||
return True, {"success": True, "reply": reply, "model": "qwen3-vl:8b"}, 42.0
|
||||
return False, "unexpected " + url, 1.0
|
||||
|
||||
monkeypatch.setattr(debug_assistent, "_http_json", fake_http)
|
||||
monkeypatch.setattr(das, "_http_json", fake_http)
|
||||
|
||||
out = debug_assistent.run_assistent_chat_eval(
|
||||
cfg,
|
||||
@@ -240,6 +257,7 @@ def test_chat_eval_mocked_http(monkeypatch, tmp_path):
|
||||
assert out["patch"]["cfg"] == 1
|
||||
assert out["patch"]["aspect"] == "3:4"
|
||||
assert "turbo" in (out["reply_prose"] or "").lower() or "turbo" in (out["reply"] or "").lower()
|
||||
assert out.get("trace") and out["trace"].get("exact_merge")
|
||||
assert calls and calls[0][1]["session_id"] == "sess-1"
|
||||
assert calls[0][1]["messages"][0]["content"] == "какой checkpoint?"
|
||||
assert calls[0][1]["includeBase"] is True
|
||||
|
||||
Reference in New Issue
Block a user