Problem
ask_question.py can return the wrong NotebookLM answer when the notebook already contains prior conversation history and/or the new answer takes time to hydrate.
In my case, the CLI kept returning the generic notebook intro:
Esse é o notebook com as possibilidades de integração com SOC...
But the browser UI had already produced the correct, much longer answer.
Reproduction
- Open a notebook with existing chat history.
- Ask a new question with
python scripts/run.py ask_question.py --question "..." --notebook-url "...".
- Use a notebook with many sources and a slower response path.
- Observe that the script can return a stale/older message instead of the newly generated answer shown in the UI.
Root cause
The current polling logic in scripts/ask_question.py:
- snapshots only the latest visible response element
- assumes
elements[-1] is the newest completed answer
- does not distinguish previously hydrated responses from the current answer
- can treat transient NotebookLM placeholders like
Reading through pages... / Finding key words... as part of the response lifecycle
- uses a fixed 120s timeout, which is tight for notebooks with many sources
Because NotebookLM chat history may hydrate asynchronously, the last response element after submit is not always the new answer. The script can therefore stabilize on an older response.
Proposed fix
I validated a local fix with these changes:
- Wait briefly for existing responses to hydrate before submitting the new question.
- Snapshot all existing assistant responses before asking.
- During polling, scan responses from newest to oldest and select the newest candidate that:
- is not the user question
- is not a known transient placeholder
- was not already present before submission
- Keep the stability check for the selected candidate.
- Increase
QUERY_TIMEOUT_SECONDS from 120 to 300.
Result
After applying the fix locally, the same notebook/query returned the correct employee export list instead of the stale intro message.
If useful, I already have a patch ready and can open a PR.
Problem
ask_question.pycan return the wrong NotebookLM answer when the notebook already contains prior conversation history and/or the new answer takes time to hydrate.In my case, the CLI kept returning the generic notebook intro:
Esse é o notebook com as possibilidades de integração com SOC...But the browser UI had already produced the correct, much longer answer.
Reproduction
python scripts/run.py ask_question.py --question "..." --notebook-url "...".Root cause
The current polling logic in
scripts/ask_question.py:elements[-1]is the newest completed answerReading through pages.../Finding key words...as part of the response lifecycleBecause NotebookLM chat history may hydrate asynchronously, the last response element after submit is not always the new answer. The script can therefore stabilize on an older response.
Proposed fix
I validated a local fix with these changes:
QUERY_TIMEOUT_SECONDSfrom120to300.Result
After applying the fix locally, the same notebook/query returned the correct employee export list instead of the stale intro message.
If useful, I already have a patch ready and can open a PR.