Repository navigation
Conversation
…accounting Agent loop - Each iteration runs in a guard: an exception in an action handler is discarded with feedback to the model and the run continues; sweep, boundary and reserve handlers tolerate a non-dict feasibility / candidate_set. - The UI callback fires only when the iteration recorded a journal entry; otherwise a UI-only "discarded" card says why. The final re-emit of the last entry is removed (it duplicated the last card and, after rejected iterations, showed a stale lower-numbered card after the last one). - journal.discarded_actions records iterations that produced no entry (kind rejected / api_error / truncated / internal, feedback, stop_reason, raw response capped at 4000 characters). Entries and statistics are unchanged. - Responses cut at max_tokens get their own message and feedback; a modify that applies no command says so; modify entries keep skipped_commands. - Optional stall breaker: AGENTIGRID_STALL_LIMIT=N stops after N consecutive iterations without a new entry (off by default). Backends - Anthropic prompt caching of the per-session system prompt (llm.prompt_cache, default on; billing only). prompt_tokens stays the total input; cache writes and reads are reported separately. - UsageMeter counts every LLM call; totals are exported as journal llm_usage. - Models that reject `temperature` are retried once without it. - LLMResponse gains api_error, stop_reason, content_types and cache fields; AGENTIGRID_MAX_TOKENS overrides the output-token cap. UI and reports - Iterations shown as "N + base case" (summary_stats adds llm_iterations and has_base_case; total_iterations unchanged). - FAILED only for solves that did not converge, not for analysis / complete / sweep / contingency / explore entries or discarded proposals. - Sidebar checkbox for the stall breaker (unchecked by default). - Default Anthropic model claude-sonnet-4-20250514 (retired) -> claude-sonnet-4-6. Tests: new tests/llm/test_prompt_cache.py and tests/journal/test_iteration_count.py; 8 new tests in tests/agent_loop/test_agent_loop.py. Fast suite: 1103 passed, 12 skipped; the 2 failures are the existing OPFLOW fixture issues fixed by the genfuel PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
4 of 20 tasks
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.
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.