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
@@ -60,7 +60,7 @@ cdef class _ReadOnlyProxy:
return f'&{funicode(self._c_node.name)};'
else:
self._raise_unsupported_type()
@property
def tail(self):
"""Text after this element's end tag, but before the next sibling
@@ -119,7 +119,7 @@ cdef class _ReadOnlyProxy:
if step > 0:
next_element = _nextElement
else:
step = -step if step != python.PY_SSIZE_T_MIN else python.PY_SSIZE_T_MAX
step = -step
next_element = _previousElement
result = []
c = 0
@@ -160,7 +160,7 @@ cdef class _ReadOnlyProxy:
def __deepcopy__(self, memo):
"__deepcopy__(self, memo)"
return self.__copy__()
cpdef __copy__(self):
"__copy__(self)"
cdef xmlDoc* c_doc
@@ -495,7 +495,7 @@ cdef class _AppendOnlyElementProxy(_ReadOnlyElementProxy):
c_next = c_node.next
tree.xmlAddChild(self._c_node, c_node)
_moveTail(c_next, c_node)
def extend(self, elements):
"""Append a copy of all Elements from a sequence to the list of
children.