feat(ai): add clarification framework for ambiguous requests#466
feat(ai): add clarification framework for ambiguous requests#466SOUMITRO-SAHA wants to merge 2 commits intogetnao:mainfrom
Conversation
Enhance system prompt with structured guidance for handling ambiguous user requests. - Add new "Clarification & Ambiguity" section with explicit rules - Include common scenarios requiring clarification (databases, dates, metrics) - Add comprehensive examples showing proper clarification behavior - Enhance persona section to balance efficiency with accuracy - Update SQL query rules to emphasize never assuming database/column names - Add guidance for asking when multiple databases exist or date ranges unspecified Fixes import in tests and adds comprehensive test coverage for all new behaviors.
🚀 Preview Deployment
Preview will be automatically removed when this PR is closed. |
|
Hello @SOUMITRO-SAHA, how did you come up with this idea? Was it because you used nao and you thought it was needed? Regarding implementation I think this is something we should have in nao, but i'm not yet a fond of the current implementation, I think it takes too many tokens in the system prompt and maybe clarification questions should be a tool that might be interactive so we offer a better UX to users. |
MatLBS
left a comment
There was a problem hiding this comment.
Thanks for this PR @SOUMITRO-SAHA ,
I would optimize the system-prompt, apply the changes and we will be ready to merge 😁
Hi @Bl3f , thank you for the feedback! I actually came up with this based on my experience using I understand your concern about token usage and your suggestion of using a tool-based, interactive approach for clarification. I agree that it would provide a better UX and be more scalable. That said, implementing a separate clarification tool feels like a larger change. For a v1 release, I was thinking this prompt-based approach could still be useful to improve behaviour quickly. We can then optimise it in v2 using a proper clarification tool, which I agree is a very good idea. Happy to align with whatever direction you prefer. |
Remove redundant "Clarification & Ambiguity" and "Examples" sections from the AI system prompt. Consolidate guidance into more concise persona instructions while preserving core behavior. - Eliminate verbose clarification examples and scenarios - Streamline efficiency vs accuracy guidance in Persona section - Consolidate database and query assumption warnings - Update corresponding tests to match new prompt structure Improves readability and reduces cognitive load for AI agents while maintaining essential guidance for handling ambiguous requests.
Summary
Enhanced the agent's system prompt to proactively ask for clarification when user queries are ambiguous, rather than making incorrect assumptions. This improves query accuracy and user experience by ensuring the agent has the necessary information before executing tools.
Type: Feature / Enhancement
Related Issue: #252
Changes Made
Modified Files
apps/backend/src/components/ai/system-prompt.tsx(208 → 273 lines)apps/backend/tests/system-prompt.test.ts(7 → 21 tests)Testing
Unit Tests
Manual Testing Needed
Before merging, please test with these scenarios: