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
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:
@@ -0,0 +1,64 @@
|
||||
"""Live HTTP regressions for the findings reported in issue #502."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from collections.abc import Iterator
|
||||
from http.server import ThreadingHTTPServer
|
||||
|
||||
import pytest
|
||||
|
||||
from campaign import INVENTORY_DEADLINE_SECONDS, _trajectory
|
||||
from http_service import Handler
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def order_service() -> Iterator[str]:
|
||||
server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
||||
server.daemon_threads = True
|
||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
host, port = server.server_address
|
||||
try:
|
||||
yield f"http://{host}:{port}"
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
thread.join(timeout=1)
|
||||
|
||||
|
||||
def test_refund_verifies_eligibility_before_processing(order_service: str) -> None:
|
||||
trajectory = _trajectory(
|
||||
order_service,
|
||||
{"intent": "refund", "order_id": "ORD-58-A"},
|
||||
"HTTP-RF-001",
|
||||
)
|
||||
|
||||
tools = [turn.get("tool") for turn in trajectory["turns"]]
|
||||
assert tools.count("verify_refund_eligibility") == 1
|
||||
assert tools.index("verify_refund_eligibility") < tools.index("process_refund")
|
||||
assert trajectory["final_status"] == "success"
|
||||
|
||||
|
||||
def test_inventory_timeout_uses_cache_within_deadline(order_service: str) -> None:
|
||||
trajectory = _trajectory(
|
||||
order_service,
|
||||
{
|
||||
"intent": "order_status",
|
||||
"order_id": "ORD-58-B",
|
||||
"sku": "SKU-42",
|
||||
},
|
||||
"HTTP-INV-001",
|
||||
)
|
||||
|
||||
stock_calls = [
|
||||
turn for turn in trajectory["turns"] if turn.get("tool") == "check_stock"
|
||||
]
|
||||
assert len(stock_calls) == 2
|
||||
assert stock_calls[0]["status"] == "error"
|
||||
assert stock_calls[1]["status"] == "success"
|
||||
assert stock_calls[1]["response"]["source"] == "cache"
|
||||
assert sum(float(turn["latency_ms"]) for turn in stock_calls) < (
|
||||
INVENTORY_DEADLINE_SECONDS * 1000
|
||||
)
|
||||
assert trajectory["final_status"] == "success"
|
||||
Reference in New Issue
Block a user