Skip to content

Planner and react: multi-clause routing, conversation context resolution, clarifying question fallback - #64

Open
prinskumar-tigergraph wants to merge 1 commit into
release_2.0.3from
feature/prompt-multi-clause-routing
Open

Planner and react: multi-clause routing, conversation context resolution, clarifying question fallback#64
prinskumar-tigergraph wants to merge 1 commit into
release_2.0.3from
feature/prompt-multi-clause-routing

Conversation

@prinskumar-tigergraph

@prinskumar-tigergraph prinskumar-tigergraph commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves the agentic planner and react agent to handle three scenarios that previously produced wrong or incomplete answers:

1. Multi-clause questions

When a question has multiple parts (e.g. "What is X? Also, what does the report say about Y?"), each clause is now assigned to its own retrieval step with a standalone search query. Previously the full compound question was passed to every retrieval tool, causing irrelevant chunks to be returned.

2. Conversation context resolution

When a follow-up question refers to something mentioned earlier (e.g. "その計画", "that plan", "its report"), the agent resolves the referent from ## Conversation and uses the full name in every retrieval call. If the conversation history contains multiple candidates and it is unclear which one is meant, the agent asks the user one short clarifying question instead of guessing.

3. Multi-part answer synthesis

The synthesizer now answers each part of a multi-part question from its matching source — structured-query results for typed graph facts, document passages for report/document content. Structured notes are not quoted as what a named report says.

Files changed

  • common/llm_services/base_llm.py — 7 lines changed (1 commit)

What is NOT in this PR

  • No graphrag__gsql__* tool routing (that is in static_query_registration)
  • No changes to tool_registry.py, KGAdmin.tsx, ui.py, or any code files

Test scenarios verified

Scenario Result
Multi-clause: both clauses answered from separate retrieval steps
Compound: structural amount + document policy background
Follow-up: "その計画" resolved to 財政投融資計画 from prior turn
No history + ambiguous reference: no wrong content returned

…ion, clarifying question fallback

- When a question refers to something from earlier in the conversation,
  resolve it from ## Conversation and use the full name in retrieval args.
  If history has multiple candidates and it is unclear which is meant,
  ask the user one short clarifying question instead of guessing.

- For each unstructured retrieval step, set the question to that clause
  only as a standalone search query. Do not pass the full multi-part
  question, a clause already covered by another step, or an unresolved
  reference from conversation history.

- When a question has multiple clauses, assign each clause to its own
  retrieval step; plan additional RAG steps for any clause not yet covered.

- Synthesizer: answer each part of a multi-part question from its matching
  source; do not mix structured notes with document-passage answers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant