Skip to content

feat: conversation-aware workspace retrieval (query enrichment) #5851

@kshitijk4poor

Description

@kshitijk4poor

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:

  1. Accept optional conversation_history parameter
  2. If query is short (< 5 words) or contains pronouns, append text from last 2-3 user messages
  3. Pass enriched query to workspace_retrieve()
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havetype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions