Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add E2E research test via PR label trigger

LearningCircuitd4327184a401
diff --git a/.github/workflows/e2e-research-test.yml b/.github/workflows/e2e-research-test.yml
new file mode 100644
index 0000000000..306aea882f
--- /dev/null
+++ b/.github/workflows/e2e-research-test.yml
@@ -0,0 +1,90 @@
+name: E2E Research Test
+
+on:
+ pull_request:
+ types: [labeled]
+
+permissions: {} # Minimal top-level for OSSF Scorecard
+
+jobs:
+ research-diff:
+ name: LDR Research on PR Diff
+ runs-on: ubuntu-latest
+ if: github.event.label.name == 'ldr_research'
+ permissions:
+ contents: read
+ pull-requests: write
+ issues: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Install dependencies
+ run: sudo apt-get update && sudo apt-get install -y jq
+
+ - name: Get PR diff
+ run: |
+ git fetch origin ${{ github.event.pull_request.base.ref }}
+ git diff origin/${{ github.event.pull_request.base.ref }}...HEAD --no-color > diff.txt
+ echo "Diff size: $(wc -c < diff.txt) bytes"
+
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.11'
+
+ - name: Install LDR
+ run: pip install -e .
+
+ - name: Run LDR Research
+ env:
+ OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
+ SERPER_API_KEY: ${{ secrets.SERPER_API_KEY }}
+ LDR_PROVIDER: ${{ vars.LDR_PROVIDER || 'openrouter' }}
+ LDR_SEARCH_TOOL: ${{ vars.LDR_SEARCH_TOOL || 'serper' }}
+ LDR_MODEL: ${{ vars.LDR_MODEL || '' }}
+ LDR_ITERATIONS: ${{ vars.LDR_ITERATIONS || '1' }}
+ MAX_DIFF_SIZE: ${{ vars.MAX_DIFF_SIZE || '8000' }}
+ run: |
+ RESPONSE=$(python scripts/ldr-diff-research.py < diff.txt)
+
+ # Check for errors
+ if echo "$RESPONSE" | jq -e '.error' > /dev/null 2>&1; then
+ ERROR=$(echo "$RESPONSE" | jq -r '.error')
+ if [ "$ERROR" != "null" ] && [ -n "$ERROR" ]; then
+ echo "❌ Error: $ERROR"
+ exit 1
+ fi
+ fi
+
+ # Extract research
+ echo "$RESPONSE" | jq -r '.research' > result.md
+ echo "✅ Research completed"
+
+ - name: Post Research Results
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ {
+ echo "## 🔬 LDR Research Results"
+ echo ""
+ cat result.md
+ echo ""
+ echo "---"
+ echo "_Generated by [Local Deep Research](https://github.com/LearningCircuit/local-deep-research) E2E test_"
+ } > comment.md
+
+ gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F comment.md
+
+ - name: Remove label for re-triggering
+ if: always()
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ gh issue edit ${{ github.event.pull_request.number }} --remove-label "ldr_research" 2>/dev/null || true
+
+ - name: Cleanup
+ if: always()
+ run: rm -f diff.txt result.md comment.md
diff --git a/scripts/ldr-diff-research.py b/scripts/ldr-diff-research.py
new file mode 100755
index 0000000000..a36753957c
--- /dev/null
+++ b/scripts/ldr-diff-research.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python3
+"""
+LDR Diff Research Script
+
+Reads a code diff from stdin and uses Local Deep Research to find
+relevant documentation, best practices, and known issues.
+
+Usage:
+ cat diff.txt | python scripts/ldr-diff-research.py
+ git diff HEAD~1 | python scripts/ldr-diff-research.py
+
+Output: JSON with 'research' field containing the markdown research results.
+
+Environment variables (required):
+ OPENROUTER_API_KEY - API key for OpenRouter (or other provider)
+ SERPER_API_KEY - API key for Serper.dev search
+
+Environment variables (optional):
+ LDR_PROVIDER - LLM provider (default: openrouter)
+ LDR_SEARCH_TOOL - Search tool (default: serper)
+ LDR_MODEL - Model name (default: provider's default)
+ LDR_ITERATIONS - Research iterations (default: 1)
+ MAX_DIFF_SIZE - Max diff size in bytes (default: 8000)
+
+Note: This uses the programmatic API and does NOT require a running LDR server.
+"""
+
+import json
+import os
+import sys
+
+
+def main():
+ # Read diff from stdin
+ diff = sys.stdin.read()
+
+ if not diff.strip():
+ print(json.dumps({"error": "No diff provided", "research": ""}))
+ sys.exit(1)
+
+ # Get settings from environment
+ provider = os.environ.get("LDR_PROVIDER", "openrouter")
+ search_tool = os.environ.get("LDR_SEARCH_TOOL", "serper")
+ model_name = os.environ.get("LDR_MODEL") # None = use provider default
+ iterations = int(os.environ.get("LDR_ITERATIONS", "1"))
+ max_size = int(os.environ.get("MAX_DIFF_SIZE", "8000"))
+
+ # Check required API keys based on provider/search tool
+ if provider == "openrouter" and not os.environ.get("OPENROUTER_API_KEY"):
+ print(
+ json.dumps({"error": "OPENROUTER_API_KEY not set", "research": ""})
+ )
+ sys.exit(1)
+
+ if search_tool == "serper" and not os.environ.get("SERPER_API_KEY"):
+ print(json.dumps({"error": "SERPER_API_KEY not set", "research": ""}))
+ sys.exit(1)
+
+ # Truncate if too large
+ if len(diff) > max_size:
+ diff = diff[:max_size] + "\n... (truncated)"
+
+ try:
+ from local_deep_research.api import quick_summary
+ from local_deep_research.api.settings_utils import (
+ create_settings_snapshot,
+ )
+
+ settings = create_settings_snapshot(
+ overrides={
+ "search.tool": search_tool,
+ }
+ )
+
+ # Build kwargs
+ kwargs = {
+ "query": f"""Based on these code changes, research relevant documentation,
+best practices, and potential issues. Focus on any libraries, APIs, or patterns used.
+
+Code changes:
+{diff}
+
+Research topics to cover:
+1. Documentation for any libraries or APIs being used/modified
+2. Best practices for the patterns shown
+3. Known issues or gotchas related to these changes
+4. Security considerations if applicable""",
+ "provider": provider,
+ "settings_snapshot": settings,
+ "programmatic_mode": True,
+ "iterations": iterations,
+ }
+
+ if model_name:
+ kwargs["model_name"] = model_name
+
+ result = quick_summary(**kwargs)
+
+ research = result.get("summary", str(result))
+ print(json.dumps({"research": research}))
+
+ except Exception as e:
+ print(json.dumps({"error": str(e), "research": ""}))
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()