Context
Depends on #67 (RAG-2). Part of the v2 RAG milestone.
What
Before building the system prompt, detect Live/device queries and inject the top relevant doc chunks.
Files: src/agent/chat.ts, src/server.ts
Logic:
- If
isLiveOrProductionQuery(latestUserMessage) is true, call retrieveLiveDocs(query, 3)
- If chunks are returned, inject them into the system prompt as a fenced block:
```
Relevant Live documentation
Title
body text…
Title
body text…
```
Constraints:
- Total injected context ≤ 1000 tokens (truncate body if needed, never truncate mid-sentence)
- Only inject for learning/question requests — skip for pure action commands ("set tempo to 120")
retrieveLiveDocs must run with a 50ms timeout; on timeout or error, silently continue without injection — never delay the agent turn
Tests in src/agent/chat.test.ts:
- System prompt includes doc chunks when
retrieveLiveDocs returns results for a Live query
- System prompt is unchanged when
retrieveLiveDocs returns []
- System prompt is unchanged for pure action commands even if
isLiveOrProductionQuery is true
Acceptance criteria
Context
Depends on #67 (RAG-2). Part of the v2 RAG milestone.
What
Before building the system prompt, detect Live/device queries and inject the top relevant doc chunks.
Files:
src/agent/chat.ts,src/server.tsLogic:
isLiveOrProductionQuery(latestUserMessage)is true, callretrieveLiveDocs(query, 3)```
Relevant Live documentation
Title
body text…
Title
body text…
```
Constraints:
retrieveLiveDocsmust run with a 50ms timeout; on timeout or error, silently continue without injection — never delay the agent turnTests in
src/agent/chat.test.ts:retrieveLiveDocsreturns results for a Live queryretrieveLiveDocsreturns[]isLiveOrProductionQueryis trueAcceptance criteria
retrieveLiveDocstimeout never adds latency to the agent response