Files
ai-agent-book/chapter5/log-diagnosis/test_replay_latency.py
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

26 lines
750 B
Python

from replay import _eval_assertion
def test_latency_under_null_latency_ms():
assertion = {
"type": "latency_under",
"params": {"tool": "test_tool", "threshold": 150},
}
traj = {
"turns": [
{"tool": "test_tool", "latency_ms": None},
{"tool": "test_tool", "latency_ms": 120},
]
}
ok, msg = _eval_assertion(assertion, traj)
assert ok
assert "最大延迟 120.0ms" in msg
def test_latency_under_missing_threshold():
assertion = {"type": "latency_under", "params": {"tool": "test_tool"}}
traj = {"turns": [{"tool": "test_tool", "latency_ms": 100}]}
ok, msg = _eval_assertion(assertion, traj)
assert not ok
assert "断言缺失阈值设置" in msg