Skip to content

Researcher: deep research reuses previously discovered sections#53

Merged
DavertMik merged 1 commit into
mainfrom
feature/deep-research-reuse
Jun 9, 2026
Merged

Researcher: deep research reuses previously discovered sections#53
DavertMik merged 1 commit into
mainfrom
feature/deep-research-reuse

Conversation

@DavertMik

Copy link
Copy Markdown
Contributor

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 Research sections for the page (even from an earlier session) and:

  1. Replay — re-runs the saved action for each previously found hidden section to check it still opens.
  2. Reuse — sections that still open are kept as-is and excluded from re-exploration, so the click budget is spent on what's actually new.
  3. Re-discover — sections whose trigger no longer works (button moved/renamed) are flagged to the discovery prompt as "this existed before, find it again", so relocated controls are recovered rather than lost.
  4. Skip — when every known section still opens and the click budget is already covered, the slow click-through is skipped (page effectively unchanged).

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 — add getPreviousResearch(hash), a TTL-free disk read of output/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, reworked performDeepAnalysis orchestration (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's rawMarkdown.
  • docs/researcher.md + CHANGELOG.md — document the reuse behavior.

Testing

  • bun test tests/unit/ → 651 pass
  • bun test tests/integration/ → 62 pass
  • bun run format, bun run lint:fix → clean
  • typecheck: no errors in changed files

🤖 Generated with Claude Code

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>
@DavertMik DavertMik merged commit 4781d5d into main Jun 9, 2026
2 checks passed
@DavertMik DavertMik deleted the feature/deep-research-reuse branch June 9, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant