notebooklm-query
Run a question against one or more libraries. Returns the answer plus citations into the original sources. The Decision-Engine agents (Steelman, Devils-Advocate, Synthesizer) can call this during reasoning to ground their arguments in Adam's curated corpus.
Pre-flight checks
- Each
library_sluginlibrariesresolves to an existingWiki/Libraries/{slug}.md. - NotebookLM session valid (Phase 2+). Phase 1 fallback: read each library's
## Cached summarybody section and return that text asanswer, withcached: trueandcitations: []. Mark this clearly in the answer so the caller knows it's not live.
Procedure
1. Decide live vs. cached
- If
mode == "fast"AND every involved library haslast_summarizedwithin the last 7 days AND the question is broad ("what does this library cover?"), prefer cached: read the## Cached summarybody section of each library node and synthesize. - For specific questions, novel topics, or
mode == "deep": live query NotebookLM.
2. Live query (Phase 2+)
- For a single library: invoke
notebooklm-pychat against that notebook withquestion. - For multiple libraries: query each in parallel, then merge — synthesize the per-library answers into one with each citation tagged by library slug.
3. Format the response
Return a structured object the caller can use:
answer: |
<synthesized prose answer>
citations:
- source_id: <id>
source_title: <title>
library: <library_slug>
snippet: <relevant excerpt>
timestamp_or_page: <e.g., "12:34" for video, "p. 42" for PDF>
cached: false
4. Log entry
- input:
libraries={libraries}, question="{question[:80]}...", mode={mode} - output:
answer_preview="{answer[:100]}...", citations={count}, cached={cached} - notes:
notebooklm-query(so it's filterable in Log)
Caller patterns
Decision-Engine
# In dialectic-cycle, after Steelman builds initial cases:
notebooklm-query:
libraries: [adam-consumption, leadership]
question: "How have similar decisions played out historically? What patterns predict failure?"
mode: deep
→ answer fed to Devils-Advocate as additional ammunition
learn-from-source
# When a podcast URL is being synthesized:
notebooklm-query:
libraries: [adam-consumption]
question: "What other sources in this library cover similar themes?"
mode: fast
→ returned related-source list becomes outbound wikilinks
Ad-hoc
/library query— Adam asks anything against any library.
Failure modes
- Session expired / 401 — surface to Adam, ask to run
notebooklm loginagain. Fall back to cached summary if available. - Rate-limited — back off; retry once after 30 seconds; on second failure, fall back to cached + flag in Log.
- Library has zero sources — return
answer: "Library is empty — add sources via /library add-source first."withcached: false, citations: []. - Question is too broad (returns nothing useful) — surface and suggest narrowing.
Hard rules
- Never pass
Context/MI.mdor sensitive vault content as part of the question prompt unless explicitly authorized for that query — the question goes to Google. - Never store the answer text from NotebookLM verbatim in long-term wiki nodes without paraphrasing — wiki nodes are yours; the citation pattern is enough provenance.
- Always log query usage so rate limits / costs are visible.