Files
ai-agent-book/tests/test_ch8_assistant_text_null_content.py
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

33 lines
1.0 KiB
Python

import pytest
import sys
import os
sys.path.insert(0, os.path.abspath("chapter9/trajectory-verifier"))
from verifier import _assistant_text, ProcessVerifier, PASS
def test_assistant_text_handles_null_content():
"""Contract: _assistant_text does not output literal 'None' for assistant tool-call messages with content: None."""
trajectory = {
"messages": [
{"role": "assistant", "content": None, "tool_calls": [{"id": "call_1"}]}
]
}
assert _assistant_text(trajectory) == ""
def test_process_verifier_privacy_tolerates_null_content_assistant_messages():
"""Contract: ProcessVerifier._privacy does not flag false positive privacy leak on content: None assistant messages."""
trajectory = {
"messages": [
{"role": "assistant", "content": None, "tool_calls": [{"id": "call_1"}]}
],
"sensitive_values": [
{"label": "auth token", "value": "None"}
]
}
pv = ProcessVerifier()
res = pv._privacy(trajectory)
assert res.verdict == PASS