feat(papers): live on-demand 'search recent papers' via opencite#310
Merged
Conversation
Adds search_<community>_papers_live, an opt-in tool that queries opencite for the most recent literature (newest first) when the user asks for recent/new papers or the local index comes up short. Results are best-effort cached into the community DB so future local searches find them. Bounded by a timeout to keep chat responsive. - search_papers_live() in papers_sync.py reuses the opencite client + _run async bridge; keys read from the server's env. - Gated by citations.live_search (new config flag, default on) wherever paper citations are configured. - EEGLAB prompt guides the agent to use it for recency. Closes #308
Address PR review: - cache live-search results in a background daemon thread so a chat response is never delayed (was synchronous; could block up to the SQLite busy timeout if the scheduler was mid-sync on the same DB). - set opencite per-request timeout just under the overall cap so each source finishes/times out cleanly before wait_for cancels, avoiding orphaned-task error noise on the timeout path. - test caching deterministically via _cache_papers_async (offline, real SQLite); live network test now just asserts result shape.
Member
Author
Review (Sonnet, pr-review-toolkit) + resolutionsNo critical issues. The reviewer confirmed the async/timeout reasoning is sound: Both 'important' findings addressed (no tech debt carried forward):
|
This was referenced Jun 5, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the live paper search idea (#308): a tool that fetches the most recent literature on demand via opencite, beyond what the batch sync has indexed. Builds directly on the opencite client added in #309.
Closes #308.
What's added
search_<community>_papers_live— a new agent tool. It queries opencite across(openalex, s2, pubmed)sorted newest-first, returns the top results, and best-effort caches them into the community knowledge DB so future local searches find them too.citations.live_searchconfig flag (default on wherever paper citations are configured). The tool description and EEGLAB prompt tell the agent to use it only when the user asks for recent / latest / new papers, or when the local index comes up short, so there's no surprise latency on ordinary questions.Design
search_papers_live()inpapers_sync.pyreuses the existing opencite client, the_runasync bridge (safe under LangGraph's asyncToolNode, which runs sync tools in a worker thread),_build_config, and_store_papers. API keys are read from the server's env vars (same ones OSA settings use).Tests
_paper_to_resultmapping (realPaper, offline).include_live_papers=True, absent by default.513tests pass across tools/knowledge/scheduler; ruff clean.Verified locally
Live call returned 2026 papers, newest-first, e.g. for "EEGLAB independent component analysis".