feat(agent): scrape linked pages to ground answers in real content

Adds `_fetch_page_content()`, which downloads a URL with a
browser-like User-Agent and uses BeautifulSoup with the lxml
parser to strip scripts, navigation, and other non-content
markup, returning up to 3000 characters of readable text.

The response validator now also compares generated replies
against this scraped text, flagging named entities and claims
that do not appear in the retrieved page content.

Dependencies: adds beautifulsoup4==4.12.3 and pins lxml==5.3.0
for parser compatibility.
This commit is contained in:
2026-10-26 16:48:29 -03:00
parent 9eed02645b
commit 723ca1506b
231 changed files with 20508 additions and 5330 deletions
@@ -69,6 +69,9 @@ cdef class Schematron(_Validator):
"""
cdef schematron.xmlSchematron* _c_schema
cdef xmlDoc* _c_schema_doc
def __cinit__(self):
self._c_schema = NULL
self._c_schema_doc = NULL
def __init__(self, etree=None, *, file=None):
cdef _Document doc
@@ -80,14 +83,6 @@ cdef class Schematron(_Validator):
if not config.ENABLE_SCHEMATRON:
raise SchematronError, \
"lxml.etree was compiled without Schematron support."
import warnings
warnings.warn(
"The (non-ISO) Schematron feature is deprecated and will be removed from libxml2 and lxml. "
"Use 'lxml.isoschematron' instead.",
DeprecationWarning,
)
if etree is not None:
doc = _documentOrRaise(etree)
root_node = _rootNodeOrRaise(etree)