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
@@ -14,12 +14,11 @@
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlIO.h>
#ifdef LIBXML_RELAXNG_ENABLED
#include <libxml/relaxng.h>
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
#include <libxml/xmlschemas.h>
#endif
/* for compatibility */
#include <libxml/parser.h>
#ifdef __cplusplus
@@ -128,8 +127,6 @@ XMLPUBFUN int
XMLPUBFUN void
xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,
unsigned maxAmpl);
XMLPUBFUN const xmlError *
xmlTextReaderGetLastError(xmlTextReaderPtr reader);
/*
* Iterators
@@ -289,7 +286,7 @@ XMLPUBFUN int
xmlTextReaderNextSibling (xmlTextReaderPtr reader);
XMLPUBFUN int
xmlTextReaderIsValid (xmlTextReaderPtr reader);
#ifdef LIBXML_RELAXNG_ENABLED
#ifdef LIBXML_SCHEMAS_ENABLED
XMLPUBFUN int
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
const char *rng);
@@ -301,8 +298,6 @@ XMLPUBFUN int
XMLPUBFUN int
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
xmlRelaxNGPtr schema);
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
XMLPUBFUN int
xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
const char *xsd);
@@ -429,11 +424,6 @@ XMLPUBFUN void
xmlTextReaderErrorFunc *f,
void **arg);
XMLPUBFUN void
xmlTextReaderSetResourceLoader(xmlTextReaderPtr reader,
xmlResourceLoader loader,
void *data);
#endif /* LIBXML_READER_ENABLED */
#ifdef __cplusplus