Clean up stale references and dead code

This commit is contained in:
Yiorgis Gozadinos 2026-02-20 15:38:29 +02:00
parent cb41f84615
commit 37f28ea8de
No known key found for this signature in database
11 changed files with 33 additions and 89 deletions

View file

@ -1,6 +1,26 @@
# Changelog # Changelog
## [Unreleased] ## [Unreleased]
### Added
- **RAG skill** (`haiku.rag.skills.rag`): haiku.skills integration with search, list_documents, get_document, ask, analyze, and research tools plus managed `RAGState`
- **`HaikuRAG.research()`**: Client method for multi-agent research
- **haiku.skills entry point**: `rag = "haiku.rag.skills.rag:create_skill"`
### Changed
- **Chat TUI**: Rebuilt on RAG skill + haiku.skills `SkillToolset`
- **Web app backend**: Rebuilt on RAG skill + `AGUIAdapter`
- **Toolsets simplified**: Removed `ToolContext`, `SessionState`, `AgentDeps`, `Toolkit`; kept core `FunctionToolset` factories
- **Research graph**: Removed `session_context` and conversational output mode
### Removed
- **`agents/chat/`**: Entire chat agent module (replaced by RAG skill)
- **`--deep` flag**: Removed from `ask` CLI (use `research` command instead)
- **`--context`/`--context-file`**: Removed from `ask` CLI
- **`tools/` state machinery**: `ToolContext`, `ToolContextCache`, `SessionState`, `AgentDeps`, `Toolkit`, etc.
## [0.30.2] - 2026-02-19 ## [0.30.2] - 2026-02-19
### Fixed ### Fixed

View file

@ -59,9 +59,6 @@ haiku-rag search "attention mechanism"
# Ask questions with citations # Ask questions with citations
haiku-rag ask "What datasets were used for evaluation?" --cite haiku-rag ask "What datasets were used for evaluation?" --cite
# Deep QA — decomposes complex questions into sub-queries
haiku-rag ask "How does the proposed method compare to the baseline on MMLU?" --deep
# Research mode — iterative planning and search # Research mode — iterative planning and search
haiku-rag research "What are the limitations of the approach?" haiku-rag research "What are the limitations of the approach?"

View file

@ -64,8 +64,7 @@ stateDiagram-v2
synthesize --> [*] synthesize --> [*]
note right of plan_next note right of plan_next
Receives session_context as background Uses prior_answers from previous iterations.
and prior_answers from conversation history.
Uses a different prompt when prior answers exist. Uses a different prompt when prior answers exist.
end note end note
``` ```
@ -73,8 +72,7 @@ stateDiagram-v2
The graph receives a `ResearchContext` containing: The graph receives a `ResearchContext` containing:
- `original_question` — the user's question - `original_question` — the user's question
- `session_context` — summary of conversation history (injected as `<background>` XML) - `qa_responses` — prior answers from previous iterations (injected as `<prior_answers>` XML)
- `qa_responses` — prior answers from semantic matching or previous iterations (injected as `<prior_answers>` XML)
When prior answers are provided, the planner uses a context-aware prompt that evaluates whether existing evidence is sufficient. If it is, the planner marks `is_complete=True` and the graph skips directly to synthesis without any searches. When prior answers are provided, the planner uses a context-aware prompt that evaluates whether existing evidence is sufficient. If it is, the planner marks `is_complete=True` and the graph skips directly to synthesis without any searches.
@ -88,7 +86,6 @@ When prior answers are provided, the planner uses a context-aware prompt that ev
- Each iteration: planner evaluates context → proposes one question → search answers it → loop back - Each iteration: planner evaluates context → proposes one question → search answers it → loop back
- Planner can decompose complex questions (e.g., "benefits and drawbacks" → start with "benefits") - Planner can decompose complex questions (e.g., "benefits and drawbacks" → start with "benefits")
- Session context resolves ambiguous references and informs planning
- Prior answers let the planner skip redundant searches - Prior answers let the planner skip redundant searches
- Loop terminates when planner marks `is_complete=True` or `max_iterations` is reached - Loop terminates when planner marks `is_complete=True` or `max_iterations` is reached

View file

@ -24,7 +24,7 @@ flowchart TB
subgraph Agents["Agent Layer"] subgraph Agents["Agent Layer"]
QA[QA Agent] QA[QA Agent]
Chat[Chat Agent] Skill[RAG Skill]
Research[Research Graph] Research[Research Graph]
RLM[RLM Agent] RLM[RLM Agent]
end end
@ -98,7 +98,7 @@ flowchart LR
### Agent Layer ### Agent Layer
Four agent types for different use cases: Three agent types and a RAG skill for different use cases:
```mermaid ```mermaid
flowchart TB flowchart TB
@ -107,12 +107,12 @@ flowchart TB
S1 --> A1[Answer] S1 --> A1[Answer]
end end
subgraph Chat["Chat Agent"] subgraph Skill["RAG Skill"]
Q2[Question] --> Tools[Tool Selection] Q2[Question] --> Tools[Tool Selection]
Tools --> S2[Search / Ask / Get] Tools --> S2[Search / Ask / Analyze]
S2 --> A2[Answer] S2 --> A2[Answer]
A2 --> History[Session History] A2 --> State[RAG State]
History -.-> Q2 State -.-> Q2
end end
subgraph Research["Research Graph"] subgraph Research["Research Graph"]
@ -138,17 +138,16 @@ flowchart TB
- Expands context around results - Expands context around results
- Generates answer with optional citations - Generates answer with optional citations
**Chat Agent** - Multi-turn conversational RAG: **RAG Skill** - Multi-turn conversational RAG via [haiku.skills](https://github.com/ggozad/haiku.skills):
- Composed from reusable [toolsets](tools.md) (search, documents, QA, analysis) - Bundles search, list_documents, get_document, ask, analyze, and research tools
- Maintains session history with prior answer recall - Managed `RAGState` for session state (citations, QA history, document filters)
- Background summarization for context continuity - Integrates with any pydantic-ai agent via `SkillToolset`
- Session-level document filtering - Powers both the Chat TUI and web application
**Research Graph** - Iterative research workflow: **Research Graph** - Iterative research workflow:
- Proposes one question at a time, evaluates the answer, then decides whether to continue - Proposes one question at a time, evaluates the answer, then decides whether to continue
- Session context resolves ambiguous references
- Prior answers let the planner skip redundant searches - Prior answers let the planner skip redundant searches
- Synthesizes structured report - Synthesizes structured report

View file

@ -60,27 +60,9 @@ evaluations run repliqa --config /path/to/haiku.rag.yaml --db /path/to/custom.la
- `--skip-qa` - Skip QA benchmark - `--skip-qa` - Skip QA benchmark
- `--limit N` - Limit number of test cases - `--limit N` - Limit number of test cases
- `--name NAME` - Override the evaluation name - `--name NAME` - Override the evaluation name
- `--deep` - Use deep QA mode (multi-step reasoning with research graph)
If no config file is specified, the script searches standard locations: `./haiku.rag.yaml`, user config directory, then falls back to defaults. If no config file is specified, the script searches standard locations: `./haiku.rag.yaml`, user config directory, then falls back to defaults.
### Deep QA Mode
The `--deep` flag enables multi-step reasoning using the research graph instead of the simple QA agent:
```bash
evaluations run repliqa --skip-db --deep
```
In deep mode:
- Questions are decomposed into sub-questions by a planning agent
- Each sub-question is answered by searching the knowledge base
- A synthesis agent combines findings into a comprehensive answer
- The graph runs for up to 2 iterations with no early exit (confidence threshold disabled)
This matches the behavior of `haiku-rag ask --deep` in the CLI. Deep mode typically produces more thorough answers but requires more LLM calls per question.
## Methodology ## Methodology
### Retrieval Metrics ### Retrieval Metrics

View file

@ -143,31 +143,17 @@ Ask questions with citations showing source documents:
haiku-rag ask "Who is the author of haiku.rag?" --cite haiku-rag ask "Who is the author of haiku.rag?" --cite
``` ```
Use deep QA for complex questions (multi-agent decomposition):
```bash
haiku-rag ask "What are the main features and architecture of haiku.rag?" --deep --cite
```
Filter to specific documents: Filter to specific documents:
```bash ```bash
haiku-rag ask "What are the main findings?" --filter "uri LIKE '%paper%'" haiku-rag ask "What are the main findings?" --filter "uri LIKE '%paper%'"
``` ```
Provide background context for the question:
```bash
haiku-rag ask "What are the protocols?" --context "Focus on security best practices"
haiku-rag ask "Summarize the findings" --context-file background.txt
```
The QA agent searches your documents for relevant information and provides a comprehensive answer. When available, citations use the document title; otherwise they fall back to the URI. The QA agent searches your documents for relevant information and provides a comprehensive answer. When available, citations use the document title; otherwise they fall back to the URI.
Flags: Flags:
- `--cite`: Include citations showing which documents were used - `--cite`: Include citations showing which documents were used
- `--deep`: Decompose the question into sub-questions answered in parallel before synthesizing a final answer
- `--filter` / `-f`: Restrict searches to documents matching the filter (see [Filtering Search Results](python.md#filtering-search-results)) - `--filter` / `-f`: Restrict searches to documents matching the filter (see [Filtering Search Results](python.md#filtering-search-results))
- `--context`: Background context for the question (passed to the agent as system context)
- `--context-file`: Path to a file containing background context
## Chat ## Chat
@ -242,18 +228,9 @@ Filter to specific documents:
haiku-rag research "What are the key findings?" --filter "uri LIKE '%paper%'" haiku-rag research "What are the key findings?" --filter "uri LIKE '%paper%'"
``` ```
Provide background context for the research:
```bash
haiku-rag research "What are the safety protocols?" --context "Industrial manufacturing context"
haiku-rag research "Analyze the methodology" --context-file research-background.txt
```
Flags: Flags:
- `--filter` / `-f`: SQL WHERE clause to filter documents (see [Filtering Search Results](python.md#filtering-search-results)) - `--filter` / `-f`: SQL WHERE clause to filter documents (see [Filtering Search Results](python.md#filtering-search-results))
- `--context`: Background context for the research
- `--context-file`: Path to a file containing background context
Research parameters like `max_iterations` and `max_concurrency` are configured in your [configuration file](configuration/index.md) under the `research` section. Research parameters like `max_iterations` and `max_concurrency` are configured in your [configuration file](configuration/index.md) under the `research` section.

View file

@ -40,8 +40,6 @@ qa:
- **max_iterations**: Maximum search iterations (default: 2) - **max_iterations**: Maximum search iterations (default: 2)
- **max_concurrency**: Number of concurrent search operations (default: 1) - **max_concurrency**: Number of concurrent search operations (default: 1)
Deep QA mode (`haiku-rag ask --deep`) uses the research graph with a single iteration for quick, focused answers.
## Research Configuration ## Research Configuration
Configure the multi-agent research workflow: Configure the multi-agent research workflow:

View file

@ -16,10 +16,6 @@ class ResearchContext(BaseModel):
qa_responses: list[Any] = Field( qa_responses: list[Any] = Field(
default_factory=list, description="Structured QA pairs used during research" default_factory=list, description="Structured QA pairs used during research"
) )
session_context: str | None = Field(
default=None,
description="Session context from previous Q&A summarization",
)
def add_qa_response(self, qa: "SearchAnswer") -> None: def add_qa_response(self, qa: "SearchAnswer") -> None:
"""Add a structured QA response.""" """Add a structured QA response."""

View file

@ -27,9 +27,6 @@ def format_context_for_prompt(context: ResearchContext) -> str:
"""Format the research context as XML for prompts.""" """Format the research context as XML for prompts."""
context_data: dict[str, object] = {} context_data: dict[str, object] = {}
if context.session_context:
context_data["background"] = context.session_context
context_data["question"] = context.original_question context_data["question"] = context.original_question
if context.qa_responses: if context.qa_responses:

View file

@ -1,7 +1,5 @@
ITERATIVE_PLAN_PROMPT = """You are the research orchestrator planning the investigation. ITERATIVE_PLAN_PROMPT = """You are the research orchestrator planning the investigation.
If a <background> section is provided, use it to understand the conversation context.
Your task: Your task:
1. Analyze the original question 1. Analyze the original question
2. Propose the first question to investigate 2. Propose the first question to investigate
@ -23,7 +21,6 @@ The question must be standalone and self-contained:
ITERATIVE_PLAN_PROMPT_WITH_CONTEXT = """You are the research orchestrator evaluating gathered evidence. ITERATIVE_PLAN_PROMPT_WITH_CONTEXT = """You are the research orchestrator evaluating gathered evidence.
You have access to context that may include: You have access to context that may include:
- <background>: Domain context for the conversation
- <prior_answers>: Previous Q&A pairs with confidence scores - <prior_answers>: Previous Q&A pairs with confidence scores
Your task: Your task:

View file

@ -89,22 +89,6 @@ def test_format_context_for_prompt_basic():
assert "What is X?" in result assert "What is X?" in result
def test_format_context_for_prompt_with_session_context():
"""Test format_context_for_prompt includes session_context as background."""
from haiku.rag.agents.research.dependencies import ResearchContext
from haiku.rag.agents.research.graph import format_context_for_prompt
context = ResearchContext(
original_question="What is Y?",
session_context="Previous discussion about topic Z.",
)
result = format_context_for_prompt(context)
assert "<background>" in result
assert "Previous discussion" in result
assert "What is Y?" in result
def test_format_context_for_prompt_with_prior_answers(): def test_format_context_for_prompt_with_prior_answers():
"""Test format_context_for_prompt includes prior_answers.""" """Test format_context_for_prompt includes prior_answers."""
from haiku.rag.agents.research.dependencies import ResearchContext from haiku.rag.agents.research.dependencies import ResearchContext