Add deep Assistent probes to the Debug API.
Expose /assistent subpaths for extension/DLL, overlay personas, roles, memory sqlite, live Assistent* API smoke, and optional chat_smoke so agents can diagnose missing tab, empty chat, and wrong models over HTTP. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -131,12 +131,139 @@ def test_debug_server_routes(monkeypatch, tmp_path):
|
||||
code, data = get("/logs")
|
||||
assert data["error"] == debug_checks.SSH_UNAVAILABLE
|
||||
|
||||
code, data = get("/assistent")
|
||||
assert "playbook" in data
|
||||
assert "hints" in data
|
||||
assert data.get("error") == debug_checks.SSH_UNAVAILABLE or data.get("extension", {}).get(
|
||||
"error"
|
||||
) == debug_checks.SSH_UNAVAILABLE or not data.get("ok")
|
||||
|
||||
code, data = get("/assistent/api")
|
||||
assert "ok" in data
|
||||
|
||||
code, data = get("/openapi.json")
|
||||
assert "/assistent/extension" in data["paths"]
|
||||
assert "/assistent/api" in data["paths"]
|
||||
|
||||
with pytest.raises(Exception):
|
||||
urllib.request.urlopen(f"http://127.0.0.1:{port}/nope", timeout=2)
|
||||
finally:
|
||||
debug_api.stop_debug_server(srv)
|
||||
|
||||
|
||||
def test_assistent_compact_and_roles_local(monkeypatch, tmp_path):
|
||||
from gpu_rent import debug_assistent
|
||||
|
||||
compact = debug_assistent._compact_api(
|
||||
"AssistentListModels",
|
||||
{
|
||||
"models": ["a:8b", "b:32b"],
|
||||
"memory_models": ["nomic-embed-text"],
|
||||
"preferred": "b:32b",
|
||||
"base_url": "http://127.0.0.1:11434",
|
||||
},
|
||||
)
|
||||
assert compact["model_count"] == 2
|
||||
assert compact["preferred"] == "b:32b"
|
||||
|
||||
_auth_env(monkeypatch, tmp_path)
|
||||
cfg = load_config(require_auth=True)
|
||||
monkeypatch.setattr(
|
||||
debug_assistent.debug_checks,
|
||||
"load_state",
|
||||
lambda: __import__("gpu_rent.state", fromlist=["SessionState"]).SessionState(
|
||||
phase="idle"
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
debug_assistent,
|
||||
"collect_assistent_fs",
|
||||
lambda cfg, **k: {
|
||||
"ok": True,
|
||||
"extensions": [
|
||||
{
|
||||
"name": "swarm-assistent",
|
||||
"path": "/mnt/swarm_data/Extensions/swarm-assistent",
|
||||
"dll": "/x/SwarmAssistentExtension.dll",
|
||||
"sqlite_dll": True,
|
||||
"tab_html": True,
|
||||
"bundle_js": True,
|
||||
"git_head": "abc",
|
||||
}
|
||||
],
|
||||
"overlay": {
|
||||
"exists": True,
|
||||
"persona_ids": ["leonid"],
|
||||
"roles_present": True,
|
||||
"roles": {
|
||||
"chat": ["qwen3-vl:8b"],
|
||||
"memory": ["nomic-embed-text"],
|
||||
"default_chat": "qwen3-vl:8b",
|
||||
},
|
||||
"embed_model": "nomic-embed-text",
|
||||
},
|
||||
"sqlite": {"exists": True, "size": 100, "counts": {"memories": 2}},
|
||||
"wanted": {"count": 0, "sample": []},
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
debug_assistent.debug_checks,
|
||||
"collect_ollama",
|
||||
lambda cfg: {"ok": True, "models": ["qwen3-vl:8b", "nomic-embed-text"]},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
debug_assistent,
|
||||
"collect_assistent_api",
|
||||
lambda cfg, chat_smoke=False: {
|
||||
"ok": True,
|
||||
"via": "local",
|
||||
"calls": [
|
||||
{"name": "AssistentListPersonas", "ok": True, "data": {"count": 3}},
|
||||
{"name": "AssistentListModels", "ok": True, "data": {"model_count": 1}},
|
||||
],
|
||||
"hints": [],
|
||||
},
|
||||
)
|
||||
deep = debug_assistent.collect_assistent_deep(cfg)
|
||||
assert deep["ok"] is True
|
||||
assert deep["extension"]["ok"] is True
|
||||
assert deep["roles"]["roles"]["default_chat"] == "qwen3-vl:8b"
|
||||
assert "playbook" in deep
|
||||
|
||||
# wrong default_chat
|
||||
monkeypatch.setattr(
|
||||
debug_assistent,
|
||||
"collect_assistent_fs",
|
||||
lambda cfg, **k: {
|
||||
"ok": True,
|
||||
"extensions": [
|
||||
{
|
||||
"name": "swarm-assistent",
|
||||
"dll": "/x.dll",
|
||||
"sqlite_dll": True,
|
||||
"tab_html": True,
|
||||
"bundle_js": True,
|
||||
}
|
||||
],
|
||||
"overlay": {
|
||||
"exists": True,
|
||||
"persona_ids": [],
|
||||
"roles_present": True,
|
||||
"roles": {
|
||||
"chat": ["missing:model"],
|
||||
"memory": [],
|
||||
"default_chat": "missing:model",
|
||||
},
|
||||
},
|
||||
"sqlite": {"exists": False, "size": 0},
|
||||
"wanted": {"count": 0, "sample": []},
|
||||
},
|
||||
)
|
||||
roles = debug_assistent.collect_assistent_roles(cfg)
|
||||
assert roles["ok"] is False
|
||||
assert any("default_chat" in h for h in roles["hints"])
|
||||
|
||||
|
||||
def test_bind_fail_returns_none(monkeypatch, tmp_path):
|
||||
_auth_env(monkeypatch, tmp_path)
|
||||
cfg = load_config(require_auth=True)
|
||||
|
||||
Reference in New Issue
Block a user