tools
zocrates.agents.online_search.tools ¶
Tools for the Online Literature Discovery Subagent.
TEMP_EXTENSION_REQUEST_PASS
module-attribute
¶
TEMP_RETRIEVAL_TOOL_BUDGET
module-attribute
¶
TEMP_RETRIEVAL_TOOL_COUNT
module-attribute
¶
CandidatePaper
dataclass
¶
CandidatePaper(candidate_id, title, authors=list(), year=None, venue=None, doi=None, arxiv_id=None, openalex_id='', abstract=None, tldr=None, is_oa=False, oa_pdf_url=None, oa_pdf_urls=list(), citation_count=0, primary_topic=None, keywords=list(), in_library=False)
Represents a discovered scholarly paper candidate.
from_dict
classmethod
¶
Deserialize CandidatePaper from a dictionary.
Source code in zocrates/discovery/models.py
to_dict ¶
Serialize CandidatePaper to a plain dictionary.
Source code in zocrates/discovery/models.py
CandidateRecommendation ¶
Bases: BaseModel
Structured paper recommendation with rationale for import.
DiscoveryEngine ¶
DiscoveryEngine(provider=None, deduplicator=None, abstract_fallback=None, unpaywall=None, email=DEFAULT_POLITE_EMAIL)
Coordinates scholarly search across providers, enforces strict novelty against the local Zotero library, backfills abstracts, and resolves Open Access PDFs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
SearchProvider | None
|
SearchProvider instance (defaults to OpenAlexProvider). |
None
|
deduplicator
|
Deduplicator | None
|
Deduplicator instance with loaded library state. |
None
|
abstract_fallback
|
AbstractFallback | None
|
AbstractFallback instance for missing abstracts. |
None
|
unpaywall
|
UnpaywallResolver | None
|
UnpaywallResolver instance for OA PDF links. |
None
|
email
|
str
|
Polite pool email for upstream academic APIs. |
DEFAULT_POLITE_EMAIL
|
Source code in zocrates/discovery/engine.py
resolve_identifier
async
¶
Resolve a single paper by DOI, arXiv ID, or OpenAlex ID and check its library presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
DOI, arXiv ID, or OpenAlex ID string. |
required |
Returns:
| Type | Description |
|---|---|
tuple[CandidatePaper | None, bool]
|
Tuple of (CandidatePaper or None, in_library boolean). |
Source code in zocrates/discovery/engine.py
search
async
¶
Search for scholarly literature, filtering out papers already in the library and enriching top results with abstracts and OA PDF URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Free-text search terms or conceptual query. |
required |
limit
|
int
|
Target number of novel candidate papers to return. |
10
|
year_from
|
int | None
|
Optional starting publication year. |
None
|
year_to
|
int | None
|
Optional ending publication year. |
None
|
is_oa_only
|
bool
|
Restrict results to open-access papers. |
False
|
Returns:
| Type | Description |
|---|---|
list[CandidatePaper]
|
List of novel CandidatePaper instances (at most |
Source code in zocrates/discovery/engine.py
_check_and_increment_online_budget ¶
Check and update tool call budget for online retrieval.
Source code in zocrates/agents/online_search/tools.py
_resolve_candidate_from_pool ¶
Resolve a candidate identifier to a CandidatePaper from the pool.
Supports multi-tier resolution:
1. Direct exact key match (cid in pool).
2. Short ID match: cid matches the suffix of a pool key (e.g., 'W3128491823' matches 'https://openalex.org/W3128491823').
3. Ordinal / Index match: if cid is 'c1', '1', 1, etc., extract integer N and map to N-1 index of pool values.
4. Direct identifier match: cid matches cand.doi or cand.arxiv_id.
Source code in zocrates/agents/online_search/tools.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
conclude_online_search ¶
Conclude the online literature retrieval phase with selected candidate papers.
Call this tool when novel, high-impact candidate papers addressing the user's research inquiry have been identified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recommendations
|
list[CandidateRecommendation]
|
Structured list of recommendations pairing candidate_id and rationale. |
required |
summary
|
str | None
|
Brief summary of the literature discovered and why these papers were selected. |
None
|
tool_context
|
ToolContext | None
|
ADK ToolContext. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message concluding the retrieval phase. |
Source code in zocrates/agents/online_search/tools.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
get_default_discovery_engine ¶
Instantiate a configured DiscoveryEngine with local Zotero deduplication.
Source code in zocrates/discovery/engine.py
request_search_extension ¶
Request permission from the user to extend the online literature retrieval budget.
Call this tool when discovering adjacent subfields or preprints that warrant deeper literature exploration beyond the initial tool budget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rationale
|
str
|
Clear explanation of why additional search queries or deeper prospecting are needed. |
required |
covered_summary
|
str | None
|
Optional summary of candidates found so far. |
None
|
missing_aspects
|
list[str] | None
|
Optional list of missing topics or subfields to explore. |
None
|
tool_context
|
ToolContext | None
|
ADK ToolContext. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message confirming extension request. |
Source code in zocrates/agents/online_search/tools.py
search_openalex
async
¶
Search OpenAlex for external scholarly papers and preprints.
Automatically excludes papers already in your local Zotero library and retrieves essential metadata, abstracts, and open-access PDF links.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Academic search query, keywords, paper title, or exact DOI/arXiv identifier. |
required |
year_from
|
int | None
|
Optional starting publication year (e.g. 2023). |
None
|
year_to
|
int | None
|
Optional ending publication year (e.g. 2025). |
None
|
is_oa_only
|
bool
|
When True, restricts results strictly to verified open-access works. |
False
|
tool_context
|
ToolContext | None
|
ADK ToolContext. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Structured summary of discovered novel candidate papers. |
Source code in zocrates/agents/online_search/tools.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |