homelabby/.planning/phases/07-research-agent-search/07-CONTEXT.md

2.2 KiB

Phase 7: Research Agent & Search - Context

Gathered: 2026-04-10 Status: Ready for planning Mode: Auto-generated (autonomous mode)

## Phase Boundary

Items flagged needs_research are automatically enriched by a SearXNG research agent, and any inventory question can be answered via natural language search. This phase delivers the SearXNG Tier 2 client, research agent that consumes needs_research items, and natural language search endpoint.

## Implementation Decisions

SearXNG Client

  • HTTP client to SearXNG JSON API at http://10.5.0.129:8080/search
  • Sanitize queries before dispatch
  • Return list of result objects (title, url, snippet)

Research Agent

  • Background worker that polls NetBox for catalog_status=needs_research items
  • For each item: query SearXNG for product info, send results to Tier 2 LLM, extract structured data
  • Update NetBox device with enriched data, set catalog_status=researched
  • Run periodically (every 10 minutes) or on-demand via POST /api/research/trigger
  • Endpoint: GET /api/search?q=...
  • Use Tier 1 (Gemma 4) to translate query to NetBox filter params
  • Return matching devices

Frontend

  • Search bar in dashboard top
  • Results page reuses dashboard cards

<code_context>

Existing Code Insights

Reusable Assets from prior phases

  • internal/ai/ — AIClient, TierClient, orchestrator
  • internal/ai/research.go — ResearchClient interface (NoOp from Phase 2)
  • internal/netbox/client.go — ListDevices, GetDevice, PatchCustomFields
  • internal/inventory/quality_gate.go + catalog_updater.go
  • internal/api/router.go
  • web/src/lib/api.ts

Integration Points

  • Replace NoOpResearchClient with real SearXNGResearchClient
  • Add internal/research/ package
  • Add internal/api/handlers/search.go
  • Frontend: dashboard search bar wires GET /api/search </code_context>
## Specific Ideas
  • SearXNG client uses standard net/http
  • Research agent runs as goroutine started from main.go
  • Search endpoint translates "show me free 10GbE NICs" to filter: category=NIC, status=available, tags has 10gbe
## Deferred Ideas
  • Saved searches
  • Search history