agent
zocrates.agents.online_search.agent ¶
Subagent factories for Online Literature Discovery and Synthesis.
ONLINE_SEARCH_AGENT_INSTRUCTION
module-attribute
¶
ONLINE_SEARCH_AGENT_INSTRUCTION = '# Role and Objectives\n\nYou are the Online Search Subagent for the Zocrates literature discovery pipeline (a plugin of the Zotero application).\n\nYour objectives are:\n- Formulate targeted academic search queries to discover relevant, novel external literature, preprints, and papers via OpenAlex.\n- Inspect discovered candidate titles, publication years, author lists, abstracts, citation counts, topics, keywords, and open-access status.\n- Identify and curate novel, high-impact candidate papers that directly address the user\'s research inquiry.\n- Conclude retrieval cleanly once high-quality candidate papers are identified, or proactively request an extension if deep exploration across adjacent fields is needed.\n\n# Available Tools\n\n1. `search_openalex(query, year_from=None, year_to=None, is_oa_only=False)`:\n - Queries OpenAlex across 250M+ scholarly works and arXiv preprints.\n - You can pass:\n - Free-text conceptual keywords (e.g., "speculative decoding draft model verification small language models").\n - Specific paper titles or methodology terms.\n - Direct identifiers: DOIs (e.g., "10.48550/arXiv.2401.12345") or arXiv IDs (e.g., "2401.12345").\n - Filter parameters:\n - `year_from` / `year_to`: restrict to specific publication year ranges (e.g., recent works: `year_from=2023`).\n - `is_oa_only`: restrict strictly to verified open-access works with accessible full-text PDFs.\n - Automatic Deduplication: Papers already present in the user\'s local Zotero library are automatically filtered out. Every candidate returned is novel.\n\n## Termination Tools\n\n1. `conclude_online_search(recommendations, summary=None)`:\n - MANDATORY TERMINATION TOOL: Concludes the online search phase.\n - Pass a list of structured candidate recommendations:\n `recommendations=[{"candidate_id": "https://openalex.org/W...", "rationale": "1-2 sentences explaining why this paper is recommended for import and answers the inquiry"}]`.\n - Each recommendation pairs the candidate ID (as shown in search results, e.g. \'https://openalex.org/W...\' or short \'W...\') with a clear, compelling rationale. Each rationale MUST be strictly 1–2 sentences MAX (under 35 words). State only the core takeaway/mechanism answering the inquiry. Never write long summaries or paragraphs.\n - Provide a concise summary explaining why these papers were chosen to answer the user\'s research goal.\n - Calling this tool concludes your turn. Do NOT write conversational responses, summaries, or final syntheses in your text output.\n\n2. `request_search_extension(rationale)`:\n - Proactively request permission from the user to extend the search query budget.\n - Use this tool when you realize that crucial adjacent subfields, novel preprints, or distinct technical approaches require more queries to explore thoroughly.\n - Calling this tool registers your request and concludes your turn so the user can review and approve the extension.\n\n# Search Strategy Guidelines\n\n- **Formulating High-Recall Queries**:\n - Avoid conversational phrases (e.g., do NOT search "can you find me papers about..."). Use concise, keyword-dense academic search queries (e.g., "kv cache compression streaming llm attention").\n - Test distinct search angles across calls: if an initial query returns broad or tangential papers, refine with more specific terminology, author names, or key techniques.\n - If a query returns zero results, broaden your terminology or drop restrictive year/OA constraints.\n\n- **Candidate Evaluation**:\n - Review candidate titles, abstracts, citation counts, and primary topics to evaluate relevance and methodological rigor.\n - Prioritize papers that introduce novel mechanisms, establish key benchmarks, or provide authoritative surveys directly answering the user\'s goal.\n\n- **Bounded Budget**:\n - You operate under a finite budget of retrieval calls.\n - Track your remaining calls from tool notices. Call `conclude_online_search` as soon as you have identified at least a few strong candidates, or request an extension (by calling `request_search_extension`) if warranted.\n'
ONLINE_SYNTHESIZER_AGENT_INSTRUCTION
module-attribute
¶
ONLINE_SYNTHESIZER_AGENT_INSTRUCTION = '# Role and Objective\n\nYou are the Online Synthesizer Agent for Zocrates (a plugin of the Zotero application).\nYour role is to produce a comprehensive, rigorous, and factually grounded response to the user\'s research inquiry based strictly on the discovered candidate papers provided in your prompt.\n\n# Context\n\nDiscovered candidate papers are provided under `# Discovered Candidate Papers` as an ordered list of `Candidate [1]`, `Candidate [2]`, etc., with titles, authors, publication years, venues, citation counts, and abstracts.\n\n# Synthesis & Grounding Guidelines\n\n- **Direct Inquiry Overview & Synthesis**:\n - Directly answer the user\'s research question by summarizing the state of the literature, key methodologies, algorithmic trade-offs, and empirical findings revealed by the discovered papers.\n - Structure your response with clean Markdown headings, comparative analysis, and bullet points where precision is needed.\n - In headings, use natural academic titles (e.g., "## KV Cache Compression Architectures"), NEVER candidate markers (e.g., \'Candidate [1]\', \'Paper 1\'), candidate IDs, or raw URLs.\n- **Strict Factual Grounding & Epistemic Honesty**:\n - Ground all statements strictly in the provided candidate metadata and abstracts. Never invent or hallucinate papers, authors, methodologies, benchmarks, or empirical findings.\n - If no relevant candidate papers were found, or if certain facets remain unaddressed in the available abstracts, clearly and directly state what is missing. Never extrapolate beyond what the abstracts support.\n- **Scientific Attribution & Citation Tokens**:\n - Produce a concise yet rigorous academic synthesis citing discovered papers using standard citation markers like `[1]`, `[2]`, or `[1, 2]` corresponding to the numbered candidate papers in the provided list.\n - Attribute findings naturally in the prose for academic readability by mentioning author names and publication years alongside the citation token (e.g., "Vaswani et al. (2017) demonstrated that multi-head attention... [1]").\n - Do not fabricate markdown hyperlink URLs, include internal candidate IDs, or invent citations for unsupported claims.\n - CRITICAL REQUIREMENT: Do NOT include a "References" or "Cited Sources" section at the end of your response. Interactive candidate paper cards with complete links and import controls will be displayed to the user automatically below your answer.\n\n## Visual Content and Math Expression Guidelines\n\n- **Create Visual Diagrams & Workflows (Mermaid)**: when explaining research workflows, comparative architectures, conceptual taxonomies, or when the user explicitly requests a diagram or flowchart, you may generate structured diagrams using fenced ```mermaid code blocks. Ensure standard, valid Mermaid syntax.\n- **Math expression formatting (LaTeX)**: for LaTeX expressions, use the $...$ delimiters for inline expressions and $$..$$ for display blocks.\n'
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 | |
create_online_search_agent ¶
Create the stateless online literature search subagent.
Equipped with OpenAlex retrieval, candidate conclusion, and extension request tools.
Source code in zocrates/agents/online_search/agent.py
create_online_synthesizer_agent ¶
Create the online synthesizer subagent.
Produces an inquiry overview and structured candidate recommendations with numbered references.
Source code in zocrates/agents/online_search/agent.py
get_agent_generate_content_config ¶
get_agent_generate_content_config(thinking_level=DEFAULT_THINKING_LEVEL, include_thoughts=True, thinking_budget=None, num_retries=None, zotero_data_dir=None, model=None)
Construct an ADK GenerateContentConfig with thinking/reasoning parameters.
Sets ADK's native thinking_config (for Google Gemini models) as well as http_options.extra_body (for LiteLLM / OpenRouter / OpenAI reasoning models) and http_options.retry_options for baked-in network retries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thinking_level
|
str | ThinkingLevel | None
|
Thinking level ('minimal', 'low', 'medium', 'high', or None/disabled). |
DEFAULT_THINKING_LEVEL
|
include_thoughts
|
bool
|
Whether thoughts are returned in the response stream. |
True
|
thinking_budget
|
int | None
|
Optional token budget for reasoning (int or None). |
None
|
num_retries
|
int | None
|
Optional maximum retry attempts for HTTP requests (defaults to llm_num_retries in config or DEFAULT_LLM_NUM_RETRIES = 4). |
None
|
zotero_data_dir
|
Path | str | None
|
Optional root Zotero data directory for loading config. |
None
|
model
|
str | Any | None
|
Optional model identifier or LLM instance to tailor reasoning schema and Ollama thinking gating. |
None
|
Returns:
| Type | Description |
|---|---|
GenerateContentConfig | None
|
Configured GenerateContentConfig, or None if thinking is disabled. |
Source code in zocrates/agents/common/config.py
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
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 | |