Repository navigation
Conversation
Adds an optional, off-by-default retrieval step that prepends reference material from a curated, provenance-tagged corpus to the LLM's per-iteration prompt. Retrieval touches the generation step only: the deterministic validator never sees it, and any retrieval failure leaves the prompt unchanged, so the run behaves exactly like the baseline. - agentigrid/rag/: modes off | basic | corrective (AGENTIGRID_RAG_MODE), cosine or local cross-encoder grader for corrective mode, Ollama embeddings + Chroma index (imported lazily), ingest with corpus hash and chunking identity, per-run retrieval telemetry. - Agent loop: retrieve with the goal text before each per-iteration call, "rag_retrieved" phase for the UI, rag_enabled / rag_config in the journal. - Launcher: RAG selector under Advanced (default Off), reranker offered only when sentence-transformers is installed, grounding caption on the live monitor and results page. - rag/corpus/ (frozen v1, 12 files) and rag/tools/: harvest of tool help and case metadata, certified schema exemplars, leakage/personal-path guard. - requirements-rag.txt (optional); core requirements unchanged. - docs/RAG_USAGE.md, README section, tests/rag/ (23 tests, no Ollama or Chroma needed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Replaces #140 (fork PR, closed so CI can run) - Depends on #151
Merge request type
Relates to
This MR updates
Summary
This PR adds optional retrieval grounding (RAG) to AgentiGrid. Before each LLM proposal, the agent can retrieve short reference material from a curated, provenance-tagged corpus and prepend it to the prompt. The corpus holds ExaGO tool help, case metadata, and certified examples of correct AgentiGrid responses. The goal is fewer proposals that are executable but structurally or methodologically wrong.
Depends on #139. This branch is stacked on the agent-loop PR, because both change
agent_loop.pyand the launcher. Until that merges, this PR also shows its commit. Please review only the last commit, "optional retrieval grounding (RAG) for LLM proposals". I'll rebase ontodeveloponce #139 is merged.Design points:
requirements-rag.txt:chromadbandrequests, plussentence-transformersfor the reranker. The corerequirements.txtis untouched, andchromadbis imported lazily.chromadb) leaves the prompt unchanged, so the run behaves like the baseline. Calls, errors and empty results are counted in the journal (rag_config.stats), so a degraded run is visible.AGENTIGRID_RAG_MODEor the launcher's Advanced panel:off;basic: the top 3 chunks with cosine similarity of at least 0.35;corrective: retrieved chunks are graded (cosine, or an optional local cross-encoder), refined to the relevant sentences, and the context is withheld when retrieval is judged irrelevant.nomic-embed-text) and the index is a local Chroma store. Nothing is sent to third parties beyond the configured LLM backend.What's included:
agentigrid/agentigrid/rag/agentigrid/agentigrid/engine/agent_loop.py,journal.pyrag_enabled/rag_configin the journalagentigrid/launcher/app.py,session_manager.pyagentigrid/rag/corpus/corpus_manifest.json(SHA-256)agentigrid/rag/tools/rag_harvest.py(tool help, case metadata),rag_schema_exemplars.py(certified by AgentiGrid's own parser, validator and modifier),corpus_guard.py(leakage and personal-path audit, freeze)agentigrid/docs/RAG_USAGE.md,README.mdagentigrid/tests/rag/Not included: the batch experiment harness (runner, evaluator, statistics) and research-specific specs. If useful upstream, these can follow as a separate PR.
Testing: 23 tests in
tests/rag/. They use fake embeddings and fake models, so they need no Ollama, Chroma or model download. They cover:case118;With
chromadbinstalled and a fake embedder, ingestingrag/corpusreproduces the manifest hash (92 chunks). Basic mode returns 3 references, corrective returns refined strips, and off returns nothing.python -m pytest -m "not slow"fromagentigrid/, without the ExaGO binaries:The changelog entry is in
agentigrid/claude_code_changes.md.Issue(s) addressed
None filed. Discussed with the maintainers on 2026-10-06.