Researcher: deep research reuses previously discovered sections#53
Merged
Conversation
Deep analysis now builds on the previous deep-research result for the same page instead of starting from scratch. It reloads the saved Extended Research sections (even from an earlier session), replays the action that revealed each, reuses the ones that still open, flags relocated triggers so the AI re-finds them, and skips discovery when the page is unchanged. - cache.ts: add getPreviousResearch (TTL-free disk read); existing cache untouched (within-session reuse stays as-is) - deep-analysis.ts: _loadPreviousExtendedSections, _replayPreviousSections, shared _executeAndAnalyze + _appendExtendedResearch, missing-section hints in discovery prompts Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Deep analysis (
/research --deep) now builds on the previous deep-research result for the same page instead of starting from scratch every run.On a deep run, the researcher reloads the saved
Extended Researchsections for the page (even from an earlier session) and:Previously, every deep run re-discovered hidden UI from scratch and could silently miss sections it had already mapped.
Why
Deep research is non-deterministic and expensive. Throwing away prior results made repeated runs slow and lossy. Reusing verified sections makes deep runs faster and stops the researcher from losing hidden UI between sessions.
Changes
src/ai/researcher/cache.ts— addgetPreviousResearch(hash), a TTL-free disk read ofoutput/research/<hash>.md. The existing cache (getCachedResearch,CACHE_TTL_MS, fingerprint TTL) is untouched — within-session reuse stays as-is; cross-session reuse is this separate read path.src/ai/researcher/deep-analysis.ts—_loadPreviousExtendedSections,_replayPreviousSections, reworkedperformDeepAnalysisorchestration (replay → skip / discover), shared_executeAndAnalyze+_appendExtendedResearch(no duplication), and data-driven missing-section hints injected into the discovery text + vision prompts.tests/unit/research-parser.test.ts— guards that the replay action code is recoverable from a parsed extended section'srawMarkdown.docs/researcher.md+CHANGELOG.md— document the reuse behavior.Testing
bun test tests/unit/→ 651 passbun test tests/integration/→ 62 passbun run format,bun run lint:fix→ clean🤖 Generated with Claude Code