Skip to content

docs(ai): investigate a web research agent with RAG ingestion #3877

Closed

Description

@dan-petty

Problem

Research in the roadmap jobs is thin: one web search tool (Firecrawl, with a DuckDuckGo fallback after this item's sibling), a code search of the repository, and the RAG index of the project. Refine, the alternatives check and the stage planner each ask the same kinds of questions: Which open tool covers this need? What does this library do in this version? Does this string or API exist upstream? Nothing keeps the answers. The same question is searched again every round, and a result is lost when the job ends.

Expected

An investigation, written as an ADR in docs/adr/ with the evidence, of an open web research agent for the project. It compares open implementations and libraries and decides which one to use, or that none fits. It covers:

  • Several technical research tools in one agent: web search (DuckDuckGo, SearXNG, Firecrawl), page fetch and extraction, search of package indexes and code hosts, upstream documentation, and the repository's own code.
  • String match over the fetched text (exact and regular-expression search over results and documents), so that a claim such as "this flag exists" is checked on the text and not on a model summary.
  • RAG ingestion of the results and of the research data into the project index (Qdrant, with a collection for research), with the source URL, the fetch date, a content hash, an expiry and the question that found it. A later question reads the index first and searches the web only for what is missing or stale.
  • The limits: egress and private data (SECURITY.md rule 13: no private code or secret in a query), the per-item and per-day budget (feat(roadmap): cost and token budgets per item and per day #3066), the request budget of the Service, and the quality of the result (a measure on real questions of the alternatives and refine jobs).

Acceptance criteria

  • The ADR names at least four open implementations or libraries that were read in source or docs (for example GPT Researcher, the open deep research agent of LangChain, STORM, Crawl4AI, SearXNG, pydantic-ai tools) with what each lacks for this project.
  • The ADR states the decision, the rejected options, the design of the research index (fields, expiry, deduplication), and the string-match tool (which existing tool, for example ripgrep or a Python regex over stored text).
  • A measure: the candidate runs on 10 recorded questions from the alternatives and refine comments of the last 30 days, and the ADR gives the hit rate and the cost per question against today's Firecrawl search.
  • A person has approved the ADR in a comment on this issue.
  • The follow-up implementation issues exist and name the ADR.

Existing tool considered

Open research agents and tools (GPT Researcher, open deep research, STORM, Crawl4AI, SearXNG), pydantic-ai tools and capabilities, ddgs, the project's own RAG index and devops ai rag-query. The investigation decides; it writes no feature code.

Related

Related: #3243 (a research toolset for the planner), #2398 (refine investigation), #2650 (alternatives), #3220 and #3221 (MCP server for the jobs), #3066 (budgets), #1389 and #1653 (RAG index of managed repositories).

Proposed design

Problem statement

The roadmap jobs search the web with one thin tool and lose each answer. Refine, the alternatives check and the stage planner ask the same research questions every round. The project needs an ADR that compares open research agents and tools, chooses one design or none, and defines a Qdrant research index with string match, expiry and budgets.

Acceptance criteria

Requirement: Open tool comparison

The ADR SHALL name at least four open research tools or libraries that were read in source or docs, each with what it lacks for this project.

Scenario: Four tools with gaps

  • WHEN A reader checks the comparison section of the ADR.
  • THEN It finds at least four named open tools, and each entry states a gap.

Requirement: Decision and rejected options

The ADR SHALL state one chosen design and at least two rejected options, each with the evidence for its rejection.

Scenario: Chosen design and rejections

  • WHEN A reader checks the decision section of the ADR.
  • THEN It finds one chosen design and at least two rejected options with reasons.

Requirement: Research index design

The ADR SHALL define the research index fields, expiry, deduplication, and the page-text storage rule.

Scenario: Index fields and expiry

  • WHEN A reader checks the research index section of the ADR.
  • THEN It finds the source URL, fetch date, content hash, expiry and question fields, and no search-result field.

Requirement: String-match tool

The ADR SHALL name the existing tool for exact and regular-expression search over fetched text.

Scenario: String-match tool named

  • WHEN A reader checks the string-match section of the ADR.
  • THEN It finds ripgrep or a named Python regex library, with the reason for the choice.

Requirement: Search chain and Brave rejection

The ADR SHALL record the search chain searxng, duckduckgo, firecrawl, the rejection of the Brave Search API, and the absence of a keep parameter.

Scenario: Search chain recorded

  • WHEN A reader checks the search section of the ADR.
  • THEN It finds the three providers in that order, the Brave rejection with its terms reason, and no keep or allows_keep field.

Requirement: Ten-question measure

The ADR SHALL report the hit rate and cost per question for 10 recorded questions from the last 30 days against the SearXNG and DuckDuckGo baseline.

Scenario: Ten-question baseline

  • WHEN A reader checks the measure section of the ADR.
  • THEN It finds 10 question IDs, the hit rate, the cost per question, and the baseline providers.

Requirement: Limits recorded

The ADR SHALL record the SECURITY.md rule 13 egress rule, the per-item and per-day budget (#3066), the Service request budget, and the quality measure.

Scenario: Limits with sources

  • WHEN A reader checks the limits section of the ADR.
  • THEN It finds each of the four limits with a source.

Requirement: Follow-up work listed

The ADR SHALL list the follow-up implementation work that its decision requires.

Scenario: Follow-up work listed

  • WHEN A reader checks the end of the ADR.
  • THEN It finds a list of follow-up work items, and each names the ADR path.

Requirement: ADR location

The ADR SHALL be a numbered Markdown file under docs/adr/ with a status and a date.

Scenario: ADR file exists

  • WHEN A reader lists docs/adr/.
  • THEN It finds a new numbered ADR file with a status and a date.

Existing Tool Considered

No alternatives check has run. No single open tool covers the whole need: GPT Researcher and LangChain open deep research cover agent orchestration but not the project Qdrant research schema, exact string match, egress rules and budgets. Crawl4AI covers page fetch and extraction, SearXNG covers search, ripgrep covers exact and regular-expression match, and Qdrant covers the index. This item writes an ADR and no feature code, so no build cost applies.

Key questions

  • Which open research agent or library should the project adopt?: No single agent. The ADR should compose maintained parts: SearXNG for search, Crawl4AI for fetch and extraction, ripgrep for string match, Qdrant for the research index, and pydantic-ai for tool orchestration. It rejects GPT Researcher, LangChain open deep research and STORM as the main agent because each lacks the project exact-match, egress and budget controls. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, src/devops_cli/ai/web_search.py, SECURITY.md]
    • Chosen: Compose SearXNG, Crawl4AI, ripgrep and Qdrant with pydantic-ai. Each part is open and maintained, and each covers one need without a home-grown agent.
    • Rejected: GPT Researcher. Covers research orchestration but lacks the project Qdrant schema, exact string match, egress rules and budgets.
    • Rejected: LangChain open deep research. Adds a large dependency and a model-summary path, not exact string match.
    • Rejected: STORM. Generates long articles and does not check a narrow claim on fetched text.
  • Which search providers form the chain?: The chain is searxng, duckduckgo, firecrawl, with failover. The Brave Search API is not used because its terms forbid storing results and it has no free tier. There is no keep parameter and no allows_keep flag. (best practice) [sources: src/devops_cli/ai/web_search.py, src/devops_cli/config/defaults.py]
    • Chosen: searxng, duckduckgo, firecrawl. Owner decision of 2026-11-07; one settings list makes the chain cheap to reverse.
    • Rejected: Add Brave Search API. Its terms forbid storing results and it has no free tier.
    • Rejected: Firecrawl only. It answers HTTP 402 and gives no baseline.
  • What should the research index store?: Fetched page text only, with the source URL taken from the fetch, the fetch date, a content hash, an expiry and the question that found it. It stores no search-result field such as title, snippet, rank or age. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: Fetched page text with fetch metadata. Stores pages, not search results, and gives the URL from the fetch.
    • Rejected: Search-result fields such as title and snippet. The index stores pages, not search results.
    • Rejected: Model summaries of pages. A summary cannot prove that an exact string exists.
  • Which string-match tool should the ADR choose?: ripgrep for exact and regular-expression search over stored text, with a Python re fallback for in-memory text. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: ripgrep. Open, maintained, fast, and returns the matching line and file.
    • Rejected: Python re only. Works on in-memory text but needs custom file walking and binary handling.
    • Rejected: Model summary check. A summary is not the text and can miss an exact string.
  • What baseline should the measure use?: Use 10 recorded questions from the alternatives and refine comments of the last 30 days. Report hit rate and cost per question against the SearXNG and DuckDuckGo baseline; Firecrawl answers HTTP 402 and gives no baseline. The measure may use any provider of the chain. (best practice) [sources: src/devops_cli/ai/web_search.py]
    • Chosen: SearXNG and DuckDuckGo baseline. Both answer, and Firecrawl answers HTTP 402.
    • Rejected: Firecrawl baseline. It answers HTTP 402 and gives no result.
    • Rejected: Brave baseline. The owner rejected Brave.
  • Which limits must the ADR record?: SECURITY.md rule 13, the per-item and per-day budget (feat(roadmap): cost and token budgets per item and per day #3066), the Service request budget, and the quality measure. [sources: SECURITY.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-08: not-applicable.
Class: docs, no search.
Tool: none found.

Activity

  1. added
    source/agent
    type/docs
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/docs. The docs prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. It is a prerequisite for future research features but does not block current work.
    • Value: Medium. It guides the choice of research agent and RAG design, saving later rework, but delivers no direct user-facing change.
    • Effort: Medium. It requires reading four or more open-source projects, designing a RAG schema, running ten measured questions, and writing the ADR.
    • Related: feat(roadmap): Evaluate a research toolset with web search for the planner #3243, which asks for a different change. Both deal with web research for the project, but #3243 adds a search_web tool to the planner toolset while the candidate writes an ADR comparing open research agents and designing a RAG ingestion index.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Plan note of 2026-11-07, from the owner's request to add a local SearXNG and the Brave Search API.

    The ADR of this item must record these points. Each has its evidence in the follow-up issues.

    1. Search layer. One web_search over a list of providers (searxng, brave, duckduckgo, firecrawl), with failover and the guard on the query. SearXNG runs in namespace devops, unmodified, with keyless engines only (AGPL-3.0: no duty for an unmodified image used over HTTP; a patch needs a new ADR).
    2. Brave terms. The Brave Search API Terms of Use (1 Sep 2026), 3(b)(i), forbid to store, cache or create a database of Search Results, except transient storage. 3(b)(xiii) forbids use of Search Results to evaluate, benchmark or improve AI models or services. So the research index stores only page text that Crawl4AI fetched, with the URL of the fetch, and no field of a search result. Code that keeps results calls web_search with keep=True, which skips Brave and Firecrawl.
    3. Measure. The acceptance criterion that compares the candidate with the Firecrawl search of today has no baseline: Firecrawl answers HTTP 402. Use SearXNG and DuckDuckGo as the baseline, run with keep=True, so that no Brave result is used to benchmark. A person decides whether to add a Brave run (owner question in the plan).
    4. The decision to keep SearXNG and Brave as providers is cheap to reverse: the providers are one list in the settings.

    The list of open tools in the ADR adds SearXNG (read in source, commit 629368e40) and the Brave Search API (terms read 2026-11-07).

  5. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Plan note of 2026-11-07 (owner decision): the Brave Search API is not used. Its terms (1 Sep 2026) forbid storing results and it has no free tier. This replaces the part of the earlier plan note that mentions Brave:

    • The search chain is searxng, duckduckgo, firecrawl. There is no keyed provider for now, and no BRAVE_SEARCH_API_KEY.
    • The keep parameter and the allows_keep flag are dropped from the design of the chain (they existed only because of the Brave terms). Every provider's hits may be kept.
    • What goes into the research index does not change: fetched page text, with the URL of the page taken from the fetch. The payload still holds no field of a search result (title, snippet, rank, age), because the index stores pages, not search results.
    • The measures of docs(ai): investigate a web research agent with RAG ingestion #3877 and feat(research): ask mode reads the index before the web #3915 may use any provider of the chain.
  6. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  7. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 5520193 (see proposed design in issue body).

    Moved to new items: #4014, #4015.

  8. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: docs. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.

  9. added
    owner/service
    on Nov 17, 2026
  10. 2 remaining items

  11. added a commit that references this issue on Nov 17, 2026
  12. added
    status/planned
    owner/service
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/planned
    status/in-progress
    on Nov 17, 2026
  13. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Pull request #6147 is ready for review. The checks passed.

    Spend: 74 model requests, 9216968 input tokens, 50957 output tokens.

  14. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-implement-devops-cli-3877-875d54 ended: succeeded.
    Image digest: sha256:95f28df9348d9893cd7358c761ef7e7b14ba47b34327348c513f291af629febf

    The last lines of its log:

    Tool call: run_command, started: git status --short
    Tool call: run_command, started: git diff --stat
    Tool call: run_command, program git, ok.
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: git log --oneline -3
    Tool call: run_command, started: git show --stat --oneline HEAD | ...
    Tool call: run_command, program git, ok.
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: git show --stat --oneline HEAD -- ...
    Tool call: run_command, started: git show HEAD:openspec/changes/3877-investigate-a-web-research-agent-with/tasks.md | grep -n ...
    Tool call: run_command, program git, ok.
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: uv run devops ci test tests/invariants/test_adr_records.py
    Tool call: run_command, started: uv run devops ci docs
    Tool call: run_command, program uv, ok.
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: git show HEAD:docs/adr/0028-a-research-agent-composes-open-tools-and-a-research-index.md | head -12
    Tool call: run_command, started: git status --short
    Tool call: run_command, program git, ok.
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: uv run devops ci openspec
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: git show HEAD:docs/adr/README.md | tail -6
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: git show HEAD:docs/adr/0028-a-research-agent-composes-open-tools-and-a-research-index.md | grep -n ...
    Tool call: run_command, program git, ok.
    Disk use of the home volume at the end of step Write ADR 0028 on a research agent and its index: 1.9 GB. Largest folders: worktree/.venv 1.5 GB, .data 220.1 MB, worktree/openspec 59.0 MB, .cache 51.7 MB, worktree/tests 33.4 MB, worktree/src 32.1 MB, worktree/docs 2.6 MB, worktree/k8s 2.3 MB.
    The checks of pull request #6147 still run after 38 s.
    The checks of pull request #6147 still run after 77 s.
    The checks of pull request #6147 still run after 115 s.
    The checks of pull request #6147 still run after 154 s.
    The checks of pull request #6147 still run after 192 s.
    The checks of pull request #6147 still run after 232 s.
    The checks of pull request #6147 still run after 271 s.
    The checks of pull request #6147 still run after 310 s.
    The checks of pull request #6147 still run after 348 s.
    The checks of pull request #6147 still run after 387 s.
    The checks of pull request #6147 still run after 425 s.
    The checks of pull request #6147 still run after 464 s.
    ✓ Took 1 item(s) to a ready pull request, stopped 0.
    
  15. removed
    owner/service
    on Nov 17, 2026
  16. removed
    status/in-review
    on Nov 17, 2026
  17. added 2 commits that reference this issue on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/aisource/agenttype/docsvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions