tools.query_arxiv module
Tool: query_arxiv Search the arXiv database for scientific papers and return their abstracts, authors, and URLs.
- async tools.query_arxiv.run(query, max_results=3)[source]
Search arXiv for papers and return their metadata as a JSON string.
This is the tool entrypoint for
query_arxiv. It clampsmax_resultsto a hard ceiling of 10, URL-encodes the query into anall:search expression, and issues an asynchronousGETagainst the public arXiv export API (http://export.arxiv.org/api/query) using anhttpx.AsyncClientwith a 10-second timeout and a customUser-Agent. The Atom response body is read and handed to_parse_arxiv_atom()viaasyncio.to_thread()so XML parsing runs off the event loop. The structured result is serialized with the sharedjsonutilmodule (imported asjson).Any failure – network error, non-2xx status (via
resp.raise_for_status()), or XML parse error – is caught, logged vialogger.exception, and surfaced to the model as an error payload rather than propagated. The only side effects are the outbound HTTP request and log output; no Redis, knowledge-graph, or LLM interactions occur.This is invoked dynamically by the tool dispatch layer when the
query_arxivtool is selected; no direct internal callers were found by name.- Parameters:
- Returns:
A JSON-encoded string. On success it has
"status": "success"and a"results"list (with a"message"noting when no papers matched); on failure it has"status": "error"and a"message"describing the problem.- Return type: