Problem
Short follow-up queries like "what about the rollback plan?" only use those 5 words for retrieval. The workspace retriever does not see prior conversation context, leading to poor recall.
Research
- Khoj:
enhance_query_with_history() appends last 2 chat messages when query is <= 3 words or contains pronouns (it, this, that, they). Simple heuristic, not LLM-based. Cheap and effective.
- Continue.dev and PrivateGPT: No query enrichment.
Proposed approach
Modify workspace_context_for_turn() in agent/workspace.py:
- Accept optional
conversation_history parameter
- If query is short (< 5 words) or contains pronouns, append text from last 2-3 user messages
- Pass enriched query to
workspace_retrieve()
- In
run_agent.py, pass conversation history to the function
Stays in user message injection path — no system prompt changes, no prompt caching impact.
Related
Part of workspace foundation (#5840)
Problem
Short follow-up queries like "what about the rollback plan?" only use those 5 words for retrieval. The workspace retriever does not see prior conversation context, leading to poor recall.
Research
enhance_query_with_history()appends last 2 chat messages when query is <= 3 words or contains pronouns (it, this, that, they). Simple heuristic, not LLM-based. Cheap and effective.Proposed approach
Modify
workspace_context_for_turn()inagent/workspace.py:conversation_historyparameterworkspace_retrieve()run_agent.py, pass conversation history to the functionStays in user message injection path — no system prompt changes, no prompt caching impact.
Related
Part of workspace foundation (#5840)