Repository navigation
fix(chat): flag unresolved [cite: N] markers instead of hiding them (#2563) - #2566
tomasbenavidez wants to merge 1 commit into
Conversation
…eng-lin#2563) Follow-up turns can stream without their citation table: the answer keeps raw `[cite: N]` markers, `references` is empty, and nothing tells the caller the claims cannot be mapped to sources. - AskResult.unresolved_citation_count counts the raw markers. - ask_result_view adds `unresolved_citations` to the MCP / REST / `ask --json` envelopes. - Text `ask` prints the answer with markup=False (Rich was swallowing the markers as markup tags) and warns, suggesting `--new`. - `--save-as-note` emits NOTE_UNRESOLVED_CITATIONS so the plain-text note's raw markers are not a silent downgrade. - Regenerate backend_static_coupling baseline (line counts only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
I checked this PR's marker pattern against the
Not tested by me: anything that needs the branch installed. That is the |
Summary
Implements the client-side signal suggested in #2563: when a chat turn streams without its citation table, callers can now see that the answer's citations could not be linked to sources, instead of getting a clean-looking answer with
references: [].While reproducing it, I found a second, related problem in text mode:
askprinted the answer as Rich markup, so[cite: 3]was parsed as a markup tag and silently dropped ("Claim [cite: 3]."printed as"Claim .").Related Issue
Refs #2563. This only adds the signal on the client side. The root cause (the server omitting the citation table on some follow-up turns) is still being investigated in the issue, so this PR should not close it.
Changes
AskResult.unresolved_citation_count: a property that counts raw[cite: N]/[cite: N, M]markers inanswer.[N]markers and prose such as[cite: N]with a literalNare not counted.ask_result_viewaddsunresolved_citations(an int, always present) to the MCPchat_ask/chat_start, REST, andask --jsonenvelopes. It reads the property withgetattrso_appstays inside its import boundary (test_app_has_no_transport_dependency_imports).ask: prints the answer withmarkup=Falseand, when markers are present, warns and suggests--new.--save-as-note: a newNOTE_UNRESOLVED_CITATIONSchat event warns that the plain-text note keeps the raw markers.backend_static_coupling.jsonwithscripts/regen_baselines.py. Only line counts changed.AskResultblock indocs/python-api.md.Test Plan
uv sync --frozenwith browser/dev/markdown/mcp/server extras)uv run pytest) for the touched areas:tests/unit/test_unresolved_citations.py(new),tests/unit/app/test_app_chat.py,tests/unit/app/test_app_serialize.py,tests/unit/cli/test_chat.py,tests/unit/mcp/test_chat.py,tests/server, andtests/_guardrails(app boundary, public surface, manifest baselines, cassettes)uv run pre-commit run --all-files)uv run mypy src/notebooklm): no new errors. The 6 reported on Windows (os.O_NOFOLLOW/O_DIRECTORY/O_NONBLOCKinmcp/_hostupload.py, two unused ignores in_auth/refresh.py) are already onmain.The full
tests/unitrun on Windows has failures that also show up on a cleanmaincheckout: symlink tests without symlink privilege, the bash-based CI workflow tests, timing-sensitive fault-server tests, and thetest_browser_oauth_token.pysurvivor-policy drift. None of them are in chat, views, or CLI chat code. I expect Linux CI to confirm.New tests use the shared
mock_fetch_tokensfixture rather than a newpatch.object(auth_module, ...)site, so the shrink-only auth patch baselines do not grow.Notes
answer, so it works for anyAskResult, including hand-built ones and the Android backend.[cite: N]markers and an emptyreferenceslist (server sends no citation table) #2563 may need (the marker numbers).🤖 Generated with Claude Code
Summary by CodeRabbit