# Incomplete Context Assembly

## The Problem

Retrieved chunks provide partial information, missing critical details needed for complete answers, causing fragmented or misleading responses.

### Symptoms

* ❌ Answer covers part of topic, omits key info
* ❌ Multi-step procedures incomplete
* ❌ Missing prerequisites or warnings
* ❌ Important context cut off mid-explanation
* ❌ Users must ask follow-up for basics

### Real-World Example

```
Documentation procedure (full):
1. Backup your data (CRITICAL)
2. Run migration script
3. Verify results
4. Restore if errors occur

Retrieved chunks:
→ Chunk 1: "Run migration script: npm run migrate"
→ Chunk 2: "Verify with: npm run verify"

Missing: Step 1 (backup) and Step 4 (restore)

AI response: "Run npm run migrate then npm run verify"

User runs it → Data loss (no backup step)
```

***

## Deep Technical Analysis

### Chunking Boundary Issues

**Procedure Split Across Chunks:**

```
Document:
"Prerequisites: Install Node.js 18+
Steps:
1. npm install
2. npm run setup
..."

If chunked at 500 tokens:
→ Chunk A: Prerequisites + steps 1-3
→ Chunk B: Steps 4-6

Query matches Step 5:
→ Only Chunk B retrieved
→ Missing prerequisites from Chunk A
→ Incomplete procedure
```

**Context Window Limitations:**

```
Retrieved 10 chunks:
→ 8,000 tokens total
→ Context window: 4,000 tokens
→ Must truncate

Last 3 chunks dropped:
→ Contain critical warnings
→ AI doesn't see them
→ Incomplete answer
```

### Retrieval K Tuning

**Too Few Chunks:**

```
K=3 (retrieve top 3 chunks):
→ May capture main concept
→ But miss supporting details
→ Incomplete picture

Example:
→ Chunk 1: API authentication basics
→ Chunk 2: OAuth flow
→ Chunk 3: Token refresh
→ Missing (K=3): Rate limits, error codes, best practices
```

**Optimal K:**

```
Testing shows:
→ K=5-10 for simple factual queries
→ K=10-20 for complex explanatory queries
→ K=20+ for comprehensive procedures

But: Larger K = more tokens, higher cost
```

### Hierarchical Information

**Parent-Child Relationships:**

```
Document structure:
Section: "Database Setup"
  - Subsection: "PostgreSQL"
    - Step: "Create user"
    - Step: "Grant permissions"

Retrieval matches "Grant permissions":
→ Retrieves only that step
→ Missing parent context (PostgreSQL setup)
→ User doesn't know which DB this applies to
```

**Context Expansion:**

```
Strategy: Retrieve parent sections too
→ Match found in subsection
→ Also retrieve parent section
→ Provides broader context
→ More complete answer
```

***

## How to Solve

**Increase retrieval K (test 10-20 chunks) + implement context expansion (retrieve parent sections) + use hierarchical chunking with parent-child links + apply reranking to surface most complete chunks + adjust chunk size to capture complete procedures + use sliding window overlap (10-15%) to avoid boundary splits.** See [Context Completeness](/rag-scenarios-and-solutions/accuracy/incomplete.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.twig.so/rag-scenarios-and-solutions/accuracy/incomplete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
