Resolving Ambiguous Follow-Up Queries: A Routing Policy

GT

GigaRAG team

Retrieval11 min read
On this page
GigaRAG article: When Queries Are Too Short to Embed Usefully for AI Agents.

When Queries Are Too Short to Embed Usefully for AI Agents

After your coding agent switches repositories or resumes following a session break, you ask: "What about the previous project?" The phrase does not identify a project on its own. Before the agent acts, it needs enough context to determine what the follow-up refers to.

For this kind of follow-up, resolve the reference before retrieval. If the available context does not identify one target, ask the user to clarify.

Quick answer

A follow-up can depend on an earlier exchange to establish its referent. Resolve the reference from reliable, scoped context before retrieval. If the available context does not establish one meaning, ask what the user means.

  • Check recent conversation for a clear project reference.
  • Check persistent project context only when it is relevant and current.
  • Retrieve documents or rewrite the query after identifying the project.
  • Ask for clarification rather than guessing when the referent remains unclear.

Why queries that are too short to embed usefully need context

When a short query leaves out the project, person, time frame, or task scope needed for the request, treat it as a context-resolution task before retrieval. Do not add missing details unless scoped context establishes them.

[!note] Do not add a project identity to a query unless scoped context establishes it. When the available records do not establish one target, ask a clarification question instead of rewriting the request.

Short is not the same as ambiguous

"Run the billing migration" is short, yet it may be specific when the active task already identifies one migration. "What about the previous project?" is different: before acting, the agent needs context that establishes what "previous" refers to.

The paper Conversational Question Answering Using a Shift of Context notes that follow-up questions can be sentence fragments that depend on preceding questions and answers. For coding-agent follow-ups, resolve the reference from context that is relevant to the request before retrieving material.

What to do when the query omits key context

Use the text of a short query as one signal, not as a complete description of the user's intent. Before searching, identify whether the request already names the project and task or whether those details must come from scoped context.

For example, "the previous project" can refer to more than one project or conversation topic. Do not choose among those meanings from the fragment alone; resolve the reference from relevant context or ask a clarification question.

Common developer-agent failure signals

Treat pronouns, relative-time expressions, omitted nouns, and references such as "that branch," "the same fix," or "the previous project" as signals to check context. If the request does not establish a target, resolve it before retrieval or ask the user to clarify.

The main risk is acting on an unresolved reference. When more than one project or task could fit, ask the user to identify the intended target rather than selecting one from a plausible result.

Contextual retrieval vs. retrieval without context

FactorWith resolved contextWithout resolved context
Query meaningUse scoped conversation or project signals to establish the referent.The fragment may not establish what "previous" refers to.
Retrieval queryAdd the established project or topic when a rewrite is needed.Do not add an unestablished project or topic to the fragment.
Routing ruleUse context only when it identifies one target within the request scope.Ask for the missing identifier when the target remains unresolved.
Next actionRetrieve material for the established target.Ask a narrow clarification question before retrieval.
Comparison of retrieval routing with resolved context and without resolved context.

How an agent resolves context before it retrieves

Step 1: classify the missing information

Start by asking what the prompt leaves out: an entity, project scope, time frame, task, or user intent. "Previous project" lacks an entity and a time rule, while "run the billing migration" may only need a known project scope.

Step 2: check scoped recent and persistent context

Check recent task state first, then consider persistent project records when they are relevant to the request. Keep records scoped to the active repository, user, and session, and apply the access controls that govern the requested material. GigaRAG can connect agents to a central Hive Mind through MCP or the API, with access controls that manage what each agent can use.

Don't blend contexts blindly.

Step 3: retrieve, rewrite, or ask

Retrieve when the available context establishes a stable target, such as a repository and task. Rewrite only with grounded details. For example, rewrite "What about the previous project?" as "Check the authentication work in payments-api" only when scoped context establishes both the repository and the work item.

The next action depends on whether trusted context establishes the missing detail. If it does not, ask one narrow question, such as "Do you mean payments-api or the mobile-app repository?" The paper Ask What’s Missing and What’s Useful: Improving Clarification Question Generation Using Global Knowledge describes clarification questions as a way to identify missing information that is useful for reducing ambiguity.

Confidence and abstention rules

Set a threshold for acting. Retrieve when one scoped record clearly supports the target; ask a clarification question when the available records support multiple targets or do not establish a current match.

A plausible rewrite is not a sufficient basis for choosing a target.

Step-by-step: resolve a short coding-agent follow-up

  1. Inspect recent conversation for a clear project or task reference.
  2. Check persistent project context for a matching, relevant project identity.
  3. Verify that the context is current enough for the requested action.
  4. Rewrite the follow-up with the identified project or topic only if scoped context establishes one target.
  5. Retrieve relevant project material using the expanded query.
  6. Ask which project the user means if the available signals do not resolve the reference.
Three-stage process for resolving a short coding-agent follow-up.

Example: "What about the previous project?"

[!tip] For coding-agent follow-ups, keep the project identity with the conversation or task that established it. Before acting on "the previous project," confirm that the record matches the active request.

The context record the agent would need

For a project record, retain its repository ID, branch or workspace, active task, user and session boundary, confirmation time, and the source of each field. These details provide the context needed to evaluate whether the record supports a follow-up.

Consider the confirmation time and scope before relying on a record for the active request. For example, a project note from a past session may not be enough when it does not identify the current workspace or task.

With relevant contextual memory: resolve, then retrieve

Suppose the user just asked the agent to fix token refresh failures in payments-api, and the active task record names that repository and issue. Under this policy, the agent can treat payments-api as the referent because the recent task state provides one scoped match.

The agent can then retrieve material about token refresh work in payments-api using that established project and task context.

Without reliable memory: ask a narrow clarification

Now change the facts: the user opened mobile-app after payments-api, while persistent memory lists both as recent. Or the only payments-api record is old enough that the current workspace may have changed.

Ask: "Do you mean payments-api or mobile-app?" A useful clarification targets the missing detail that distinguishes the available options rather than asking the user to repeat the whole task.

What the agent must not assume

Do not treat "previous" as the last project in a global log, another user's project, or a vector-search match. Rewrite the query with a repository name only when a scoped record establishes that name for the request.

Plausibility does not establish the intended target.

Memory boundaries for contextual retrieval

Keep project and user scopes separate

Store project context with the boundaries needed to use it safely: the repository or workspace, the user and session that established it, the related task, and the record source. These fields let the agent decide whether a record belongs to the active request.

A project name by itself is not enough to establish the request scope.

Connect context to access controls

Apply the same access controls to context-assisted retrieval that apply to a direct search. A project reference may help form a retrieval request, while access controls determine what the agent can use.

GigaRAG provides access controls for what each connected agent can use. Keep those controls in place when an agent uses shared project knowledge across sessions or tools.

Record provenance and confirmation time

Retain where each context field came from and when it was confirmed. Use that information alongside project, user, and session scope when deciding whether the field supports a query rewrite.

If the record does not establish one target for the active request, leave the query unrevised and ask the user for the missing identifier.

Handle competing context records

When records name different projects, tasks, or workspaces, do not merge them into one retrieval request. Compare their scopes with the active request and ask a clarification question if none provides a single supported target.

Use only the context needed to establish the request target. Keep unrelated stored notes out of the retrieval query and preserve the original wording of the user's request.

A practical policy for short queries in coding agents

Build the policy around scoped evidence rather than convenience. Store enough state to resolve a reference, retain where that state came from, and ask for clarification when the available context does not establish one target.

Policy controls for safely handling short coding-agent queries.

Minimum context fields to persist

Keep a project ID, repository or workspace, user scope, active task, branch or issue when relevant, confirmation time, source record, and access boundary. Keep them separate by session and project.

Retain the source and confirmation time for each project field so the agent can assess whether the record applies to the active request.

Safe query-rewrite guardrails

Rewrite only after one target is supported by scoped context. Attach the resolved project as a retrieval filter, preserve the original prompt in logs, and record which fields supplied the missing meaning.

Do not rewrite from an unscoped global "last project" value. Require a project record tied to the relevant user, session, or task.

Clarification prompts that minimize user effort

Ask for the one missing field that decides the route: "Do you mean payments-api or the mobile app?" Focused clarification questions seek useful missing information and reduce ambiguity.

Test these prompts with fragments, pronouns, and follow-ups after a project switch.

Applying this policy with shared agent memory

When teams use shared memory, keep project knowledge scoped to the agent's request and permitted access. GigaRAG supports shared project knowledge across sessions and tools, so use its access controls to manage what each connected agent can use rather than treating all stored context as available to every agent.

Frequently asked questions

How should an agent handle an ambiguous follow-up query?

First, check whether reliable, scoped context establishes the subject of the follow-up. If it does, retrieve material for that target. If it does not, ask the user for the missing detail before retrieval.

Can a better embedding model understand "the previous project" by itself?

Do not treat the phrase alone as enough to choose a project. Use reliable, scoped context to establish the reference; if that context does not identify one project, ask the user to clarify.

When should an AI agent use conversation history instead of document retrieval?

Use conversation history to resolve a reference when the preceding exchange clearly identifies its subject. Retrieve documents after resolving the subject if the answer requires project information.

When should an agent rewrite a short query?

Rewrite it after the intended subject is established, adding that subject to the follow-up before retrieval. Do not use rewriting to invent a referent that the available context does not establish.

When should an agent ask a clarification question instead of guessing?

Ask when conversation and relevant project context do not identify a reliable referent, or when they point to conflicting possibilities. Clarification can identify useful information missing from the current context.

What context should a coding agent store for follow-up requests?

Keep enough context to identify the project and the task or exchange that established the reference. The agent should also check that this context is still relevant before relying on it.

How should an agent handle an older project record?

Compare the record's project, user, session, task, and confirmation time with the active request. If those fields do not establish one current target, ask a clarification question before retrieving or acting.

How do access controls affect contextual retrieval?

Apply access controls after using context to identify a project, just as you would for a direct search. A resolved project reference can help route the request, but the agent should use only material it is permitted to access.

About GigaRAG

GigaRAG is a shared memory platform for AI agents that helps developers and teams keep project knowledge available across sessions and tools. Connect agents to a central Hive Mind through MCP or the API, then use access controls to manage what each agent can use.

All posts