阶段4(上):LangGraph、Function Calling、MCP(SDK 2.x)、Agent 评测与运维、Agent 设计专题;run_examples 设置 RUN_EXAMPLES=1
This commit is contained in:
1 parent
6650f7eb6d
commit
caaec830b3
38 files changed
+3515
-64
No files matched your search
@@ -0,0 +1,29 @@
|
||||
# requires: pytest
|
||||
from pathlib import Path
|
||||
|
||||
import patterns as p
|
||||
|
||||
|
||||
def test_replan_after_failure():
|
||||
steps, log = p.plan_and_execute("生成 2026-09 报表")
|
||||
assert "query_sales 失败" in log[1] and all(s.status == "done" for s in steps)
|
||||
|
||||
|
||||
def test_give_up_after_max_replans():
|
||||
steps, log = p.plan_and_execute("生成报表(没有月份)", max_replans=1)
|
||||
assert log[-1].startswith("超过最大重新规划次数")
|
||||
|
||||
|
||||
def test_skill_index_is_small_and_body_loaded_on_demand():
|
||||
skills = p.discover_skills(Path(p.__file__).parent / "skills")
|
||||
idx = p.skills_index(skills)
|
||||
assert "500" not in idx and len(skills) == 2 # 索引里没有技能全文
|
||||
assert p.pick_skill("帮我统计上月订单", skills).name == "sql-report"
|
||||
assert p.pick_skill("今天天气", skills) is None
|
||||
|
||||
|
||||
def test_context_keeps_recent_and_summary():
|
||||
ctx = p.Context(system="s", budget=20, keep_recent=2)
|
||||
for t in ["订单 A1", "好", "地址 上海 1 号", "嗯", "发票", "可以"]:
|
||||
ctx.add("user", t)
|
||||
assert len(ctx.messages) == 2 and "A1" in ctx.summary
|
||||
Reference in new issue
Block a user