ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
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

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
@@ -0,0 +1,46 @@
"""Recurring timers with interval_seconds <= 0 must not busy-loop."""
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
import timer_tools as t
async def _probe(interval):
t._active_timers.clear()
t._timer_tasks.clear()
result = await t.set_recurring_timer(interval, max_occurrences=None, timer_name="probe")
await asyncio.sleep(0.05)
for task in list(t._timer_tasks.values()):
task.cancel()
await asyncio.sleep(0)
return result
def test_zero_interval_rejected():
result = asyncio.run(_probe(0))
assert result["success"] is False
assert "positive" in result["error"]
assert t._active_timers == {}
def test_negative_interval_rejected():
result = asyncio.run(_probe(-5))
assert result["success"] is False
assert t._active_timers == {}
def test_positive_interval_still_accepted():
async def run():
t._active_timers.clear()
t._timer_tasks.clear()
result = await t.set_recurring_timer(60, max_occurrences=1, timer_name="ok")
for task in list(t._timer_tasks.values()):
task.cancel()
await asyncio.sleep(0)
return result
result = asyncio.run(run())
assert result["success"] is True
assert result["interval_seconds"] == 60