aboutsummaryrefslogtreecommitdiffstats
path: root/test_llamachat.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-25 18:42:40 +0200
committerDanilo M. <danix@danix.xyz>2026-08-25 18:42:40 +0200
commit6ae195baa09bc217d51f3fb0a38312dfdcc85fdb (patch)
treef6e0f19af4bb0931fe23cd7cf65381e3e87930d2 /test_llamachat.py
parent767636465e43eb9662cde31037392d4b9c05a735 (diff)
downloadllamachat-6ae195baa09bc217d51f3fb0a38312dfdcc85fdb.tar.gz
llamachat-6ae195baa09bc217d51f3fb0a38312dfdcc85fdb.zip
fix: honor skills_enabled on restore, and final-review polish
Diffstat (limited to 'test_llamachat.py')
-rwxr-xr-xtest_llamachat.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/test_llamachat.py b/test_llamachat.py
index d96b599..71a2c35 100755
--- a/test_llamachat.py
+++ b/test_llamachat.py
@@ -3156,6 +3156,7 @@ def test_date_note():
# keeps its instructions.
class _Cfg:
search_enabled = True
+ skills_enabled = False
class _Win:
cfg = _Cfg()
@@ -3183,6 +3184,7 @@ def test_date_note():
class _Off(_Bare):
class cfg:
search_enabled = False
+ skills_enabled = False
assert _Off._system_messages(_Off()) == []
print("ok date note")
@@ -3425,6 +3427,63 @@ def test_skill_round_cap():
print("ok skill round cap")
+def test_tools_combined():
+ import urllib.request
+
+ from llamachat import search, skills
+
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ _write_skills(root, {"finance-cli/SKILL.md": SKILLS_SAMPLE["finance-cli/SKILL.md"]})
+ store = skills.SkillStore(root)
+
+ client = backend.Client("http://x")
+ sent_tools = []
+
+ def always_tool_calls(model, messages, tools):
+ sent_tools.append(tools)
+ yield from _tool_round()
+
+ client._stream_once = always_tool_calls
+ search_cfg = backend.SearchConfig(
+ enabled=True, url="http://searx", max_searches=1
+ )
+ skills_cfg = backend.SkillsConfig(enabled=True, store=store, max_searches=1)
+ original = _with_urlopen(json.dumps({"results": []}).encode())
+ try:
+ list(client.stream_chat(
+ "m", [{"role": "user", "content": "hi"}], search_cfg, skills_cfg
+ ))
+ finally:
+ urllib.request.urlopen = original
+
+ # Both schemas are offered together; the shared cap withdraws both
+ # on the final round.
+ assert len(sent_tools) == 2, sent_tools
+ assert sent_tools[0] == [search.TOOL_SCHEMA, store.tool_schema()], sent_tools[0]
+ assert sent_tools[-1] is None, sent_tools[-1]
+ print("ok tools combined")
+
+
+def test_skills_directory_truncation():
+ from llamachat import skills
+
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ path = root / "long-desc" / "SKILL.md"
+ path.parent.mkdir(parents=True)
+ path.write_text(
+ "---\nname: long-desc\n"
+ f"description: {'x' * 300}\n---\n\nbody\n"
+ )
+ store = skills.SkillStore(root)
+ directory = store.directory()
+ assert "long-desc" in directory
+ # The 300-char description is capped for the model's listing.
+ assert len(directory) < 200, len(directory)
+ print("ok skills directory truncation")
+
+
def test_title_cleaning():
clean = backend.clean_title
@@ -3773,6 +3832,8 @@ if __name__ == "__main__":
test_skill_tool_round()
test_skill_tool_errors()
test_skill_round_cap()
+ test_tools_combined()
+ test_skills_directory_truncation()
test_title_cleaning()
test_title_request()
test_needs_title()