Skip to content

Refactor analysis sandbox with document VFS and expanded search#342

Merged
ggozad merged 24 commits intomainfrom
feat/analysis
Apr 20, 2026
Merged

Refactor analysis sandbox with document VFS and expanded search#342
ggozad merged 24 commits intomainfrom
feat/analysis

Conversation

@ggozad
Copy link
Copy Markdown
Owner

@ggozad ggozad commented Apr 14, 2026

Added

  • Document virtual filesystem in analysis sandbox: Documents mounted at /documents/{id}/ with metadata.json (eager), content.txt (lazy), and items.jsonl (lazy). Standard Python pathlib.Path for browsing and reading document content and structure.
  • execute_code skill tool: Direct code execution in the sandbox, surfaced as individual AG-UI events in the chat TUI. Items VFS uses a lazy bulk cache (~1s for 1000 documents vs 60s+ per-document queries).
  • cite skill tool: Explicit citation registration with per-turn tracking via citation_index and citations fields in state
  • --skill flag for chat TUI: haiku-rag chat -s rag -s analysis to enable specific skills
  • --model overrides all agents: Chat, QA, research, and analysis agents all use the specified model
  • Collapsible program display in chat TUI: Analysis code execution results shown as expandable code blocks

Changed

  • BREAKING: Flatten skill architecture: Skill sub-agents now call search, execute_code, cite, list_documents, get_document directly — every tool call surfaces as an AG-UI event. Removes the 3rd agent layer where ask/analyze/research spawned inner agents whose tool calls were invisible.
  • BREAKING: Rename RLM agent to analysis agent throughout:
    • agents/rlm/agents/analysis/, all classes renamed (RLMResultAnalysisResult, etc.)
    • client.rlm()client.analyze()
    • CLI: haiku-rag rlmhaiku-rag analyze
    • MCP: rlm_questionanalyze
    • Config: rlm:analysis: in YAML, RLMConfigAnalysisConfig
    • Skill entrypoint: rag-rlmrag-analysis
  • Analysis sandbox search() returns expanded results with doc_item_refs and labels for cross-referencing with items.jsonl
  • list_documents skill tool takes no parameters — returns all documents
  • Per-turn citation tracking: citation_index: dict[str, Citation] (deduplicated) + citations: list[list[str]] (per-turn chunk IDs) replaces flat citation list
  • Search rate limiting: Skill search tool enforces config.qa.max_searches
  • Context expansion respects section boundaries: Sections within the char budget are returned whole regardless of item count. Too-large sections expand bounded by section edges. Adjacent sections no longer merge — only overlapping ranges do.
  • Visualization shows full expanded section: visualize_chunk expands context before resolving bounding boxes, so all pages the section spans get highlighted.

Removed

  • ask skill tool: Replaced by direct search + cite — the skill sub-agent searches and answers directly
  • analyze skill tool: Replaced by direct execute_code + search + cite
  • research skill tool: Removed from skill layer (still available via CLI haiku-rag research and MCP)
  • get_document(), get_docling_document(): Removed from analysis sandbox — replaced by VFS
  • get_chunk(): Removed from analysis sandbox — search results include expanded context
  • create_analysis_toolset(): Removed unused tools/analysis.py module
  • qa_history, reports from skill state: Conversational context handled by the outer chat agent
  • combine_filters, build_document_filter: Removed from public API
  • max_context_items: Removed from SearchConfigmax_context_chars is the sole expansion constraint
  • QAHistoryEntry, tools/qa.py: Removed unused QA history model and relevance threshold

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 96.88474% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.78%. Comparing base (1049586) to head (8e555ab).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
...slim/haiku/rag/store/repositories/document_item.py 73.68% 5 Missing ⚠️
haiku_rag_slim/haiku/rag/mcp.py 33.33% 2 Missing ⚠️
...aiku_rag_slim/haiku/rag/agents/analysis/sandbox.py 99.27% 1 Missing ⚠️
haiku_rag_slim/haiku/rag/client.py 95.65% 1 Missing ⚠️
..._rag_slim/haiku/rag/store/repositories/document.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #342      +/-   ##
==========================================
- Coverage   92.18%   91.78%   -0.41%     
==========================================
  Files          75       73       -2     
  Lines        3954     3942      -12     
==========================================
- Hits         3645     3618      -27     
- Misses        309      324      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggozad ggozad force-pushed the feat/analysis branch 3 times, most recently from 12561ed to 0fa7271 Compare April 16, 2026 11:00
@ggozad ggozad changed the title Rename RLM agent to analysis and replace get_chunk with get_context Refactor analysis sandbox with document VFS and expanded search Apr 16, 2026
@ggozad ggozad merged commit 2cd4a85 into main Apr 20, 2026
4 of 5 checks passed
@ggozad ggozad deleted the feat/analysis branch April 20, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant