Skip to main content
Glama
60-intent-clarification-enhancement-system.md19.3 kB
# PRD #60: Intent Clarification and Enhancement System **GitHub Issue**: [#60](https://github.com/vfarcic/dot-ai/issues/60) **Status**: ✅ **COMPLETED** **Priority**: High **Owner**: TBD ## Problem Statement Users frequently provide vague or incomplete intents that result in generic solution recommendations that don't match their actual requirements. The current system generates solutions based on limited information, leading to suboptimal recommendations and requiring multiple iterations to achieve desired outcomes. **Current Broken User Experience**: - **User Input**: "create postgresql database in Azure" - **System Output**: 5 generic PostgreSQL solutions without understanding specific needs - **Missing Context**: Schema management requirements, accessibility needs, performance expectations, compliance requirements - **Result**: User must manually evaluate solutions that may not fit their actual use case **Impact on User Journey**: - **Time Waste**: Users spend time reviewing irrelevant solutions - **Poor Matches**: Solutions don't align with actual technical requirements - **Iterative Frustration**: Multiple rounds of refinement to get suitable recommendations - **Missed Opportunities**: System doesn't leverage organizational patterns effectively ## Success Criteria ### Primary Objectives 1. **Enhanced Intent Quality** - Users provide more specific, actionable intents through guided clarification 2. **Better Solution Relevance** - Solutions closely match user's actual requirements and constraints 3. **Improved User Confidence** - Users feel confident their needs are understood before seeing solutions 4. **Faster Time to Value** - Reduced iterations between intent and acceptable solution 5. **Pattern Leverage** - Organizational patterns inform question generation for better governance ### Validation Test Cases - **Vague Database Request** → Specific questions about schema, accessibility, compliance → Enhanced intent → Targeted solutions - **Generic Web App Request** → Questions about architecture, scaling, security → Enhanced intent → Appropriate solutions - **API Deployment Request** → Questions about authentication, rate limiting, integrations → Enhanced intent → Relevant solutions ### Success Metrics 1. **Question Engagement Rate** - % of users who answer at least one clarification question 2. **Enhanced Intent Adoption** - % of users who proceed with enhanced vs. original intent 3. **Solution Selection Confidence** - User satisfaction with recommended solutions 4. **Reduced Iteration Rate** - Fewer cycles between recommendation and final deployment 5. **Pattern Application Improvement** - Better alignment with organizational patterns ## Solution Approach ### Phase 1: Core Intent Analysis and Question Generation 🧠 **Objective**: Implement AI-powered analysis of user intents to generate relevant clarification questions **Implementation Areas**: - **Intent Analysis Engine** - AI service that analyzes user intent for ambiguities and opportunities - **Question Generation Logic** - AI-driven question creation based on intent analysis + organizational patterns - **Question Quality Assurance** - Ensure questions are relevant, clear, and actionable - **Pattern Integration** - Leverage organizational patterns to inform question relevance **Tasks**: - [x] **Design intent analysis prompt** - AI template for analyzing user intents and identifying clarification opportunities ✅ - [x] **Implement question generation AI service** - Core logic for creating relevant questions based on intent + patterns ✅ - [x] **Create question formatting system** - Structure questions with categories, multiple choice options, examples ✅ - [x] **Integrate organizational pattern context** - Use patterns to inform domain-specific questions ✅ - [x] **Add question quality validation** - Ensure generated questions meet relevance and clarity standards ✅ **Deliverables**: Working intent analysis system that generates meaningful clarification questions ### Phase 2: Client Agent Integration and User Interface 💬 **Objective**: Integrate clarification system with client agents and create smooth user experience **Implementation Areas**: - **MCP Tool Integration** - New MCP tools for intent clarification workflow - **Client Agent Support** - Enable agents to present questions and collect responses - **User Experience Design** - Clear, optional question flow that encourages engagement - **Skip/Proceed Options** - Easy paths for users who want to proceed with original intent **Tasks**: - [x] **Create intent clarification MCP tool** - Tool for generating and presenting clarification questions ✅ - [x] **Design question presentation format** - Structure for client agents to display questions effectively ✅ - [x] **Implement answer collection system** - Mechanism for gathering and validating user responses ✅ - [x] **Add skip/proceed functionality** - Clear options for users to bypass questions ✅ - [x] **Create progress indicators** - Show users where they are in the clarification process ✅ **Deliverables**: Seamless integration with client agents supporting question-answer workflows ### ~~Phase 3: Enhanced Intent Synthesis~~ ❌ **DEFERRED - OUT OF SCOPE** **Status**: Deferred to future enhancement based on design decision analysis **Original Objective**: Combine original intent with user answers to create improved, actionable intent specifications **Decision Rationale**: This phase contradicts the core design goal of **user agency and learning**. The system should help users learn to provide better intents themselves, not replace user thinking with AI synthesis. Having AI automatically enhance intents behind the scenes removes user control and defeats the educational purpose. **Alternative Approach**: Current 2-phase system already achieves the goal perfectly - users see clarifying questions, learn what makes good deployment intents, and provide refined specifications themselves. ### ~~Phase 4: Comprehensive Validation and Optimization~~ ❌ **DEFERRED - OUT OF SCOPE** **Status**: Deferred to future enhancement based on design decision analysis **Original Objective**: Validate system performance, user adoption, and solution quality improvements **Decision Rationale**: Current system is already **complete and production-ready**. Adding analytics, extensive validation, and optimization represents over-engineering at this stage. Real-world usage will naturally provide validation and drive future optimization priorities. **Alternative Approach**: Let the system prove value through organic usage. Add validation and optimization features only if real user feedback demonstrates specific needs. ## Technical Scope ### Integration Points - **New MCP Tools**: Intent clarification and enhancement tools for client agents - **AI Service Extensions**: New prompts for intent analysis and question generation - **Recommendation Pipeline**: Integration point before existing pattern discovery and solution generation - **Client Agent Support**: Enhanced interaction capabilities for question-answer workflows ### Implementation Areas - **Intent Analysis Pipeline**: AI-powered analysis of user intents for clarification opportunities - **Question Generation System**: Dynamic creation of relevant questions based on intent + patterns - **Answer Processing**: Collection and validation of user responses - **Intent Synthesis**: Combination of original intent with answers to create enhanced specifications - **Quality Assurance**: Validation systems for question relevance and enhanced intent quality ### Technical Challenges - **AI Prompt Engineering**: Creating prompts that generate consistently relevant, high-quality questions - **Performance Optimization**: Minimizing latency impact while adding new processing phase - **User Experience Integration**: Seamless integration with diverse client agent capabilities - **Quality Control**: Ensuring enhanced intents are genuinely better than original specifications ## Dependencies & Constraints ### Dependencies - ✅ **Claude AI Integration** - Question generation and intent synthesis require AI capabilities - ✅ **MCP Framework** - Client agent integration depends on MCP tool support - ✅ **Organizational Patterns** - Pattern-informed questions require existing pattern discovery system - ✅ **Existing Recommendation Pipeline** - Enhanced intents must integrate with current solution generation ### Constraints - **Performance Impact** - Additional AI processing must not significantly slow user experience - **User Experience Quality** - Questions must provide clear value or users will skip consistently - **Client Agent Compatibility** - Must work across different client agent implementations - **Backward Compatibility** - Original intent flow must remain available as fallback ## Risks & Mitigations ### Risk: Poor Question Quality - **Impact**: Irrelevant or confusing questions reduce user engagement and trust - **Mitigation**: Robust prompt engineering, quality validation, and user feedback loops ### Risk: User Adoption Failure - **Impact**: Users consistently skip questions, reducing system value - **Mitigation**: Clear value proposition, optional engagement, and continuous UX refinement ### Risk: Performance Degradation - **Impact**: Additional AI processing makes system feel slow - **Mitigation**: Parallel processing where possible, caching strategies, performance monitoring ### Risk: Enhanced Intent Quality Issues - **Impact**: Synthesized intents are worse than originals or contain contradictions - **Mitigation**: Quality validation, fallback to original intent, continuous improvement ### Risk: Complexity Without Value - **Impact**: Added complexity doesn't translate to measurably better outcomes - **Mitigation**: Clear success metrics, A/B testing capabilities, rollback strategy ## Success Metrics ### Quantitative Metrics - **Question Engagement Rate**: Target 60%+ users answer at least one question - **Enhanced Intent Adoption**: Target 70%+ users proceed with enhanced intent - **Solution Selection Improvement**: 25%+ increase in user satisfaction with recommended solutions - **Iteration Reduction**: 30%+ reduction in cycles between recommendation and deployment - **Performance Impact**: <500ms additional latency for question generation ### Qualitative Metrics - **Question Relevance**: User feedback indicates questions help clarify actual needs - **Enhanced Intent Quality**: Synthesized intents demonstrate clear improvement over originals - **User Experience**: Clarification process feels helpful rather than burdensome - **Solution Alignment**: Recommended solutions better match user's actual requirements ## Out of Scope ### Not Included in This PRD - **Multi-Round Clarification** - Complex back-and-forth question flows (start with single round) - **Question Personalization** - User-specific question preferences or learning (future enhancement) - **Advanced Intent Validation** - Complex validation of enhanced intent feasibility (rely on existing systems) - **Question Templates** - Pre-built question sets for specific domains (rely on AI generation) ### Future Considerations - **Progressive Clarification** - Multi-step question flows for complex intents - **Learning System** - AI improves question generation based on user interactions - **Domain Expertise** - Specialized question generation for specific technology domains - **Intent History** - Leverage user's previous intents to inform question generation ## Work Log ### 2025-08-14 - Phase 1: Core Intent Analysis Implementation ✅ **COMPLETED** **Milestone: Core Intent Analysis and Question Generation** - [x] **Design intent analysis prompt** - Created comprehensive AI template in `prompts/intent-analysis.md` - [x] **Implement question generation AI service** - Added `analyzeIntentForClarification()` method to Claude service - [x] **Create question formatting system** - Implemented structured response with categories, impact levels, and suggested questions - [x] **Integrate organizational pattern context** - Template supports organizational patterns for informed question generation - [x] **Add question quality validation** - Robust error handling with fallback responses **Key Implementation Decisions:** - **Single-tool approach**: Extended existing `recommend` tool with `final: boolean` parameter instead of separate clarification tool - **User-centric design**: System provides clarification questions for user consideration rather than AI-enhanced intents - **Stateless architecture**: No session tracking needed - `final: true` indicates user has considered clarification - **Graceful degradation**: System continues with original intent if analysis fails **Technical Architecture:** ```typescript // Phase 1: Analysis (default) recommend({ intent: "deploy web app" }) // Returns: { status: "clarification_available", questions: [...], agentInstructions: "..." } // Phase 2: Final recommendation recommend({ intent: "deploy Node.js web app with PostgreSQL", final: true }) // Proceeds with normal recommendation flow ``` **Replaced Legacy System:** - ❌ Removed binary intent validation (`validateIntentWithAI`) - ❌ Removed `prompts/intent-validation.md` - ✅ Added comprehensive intent analysis system - ✅ Updated all tests to match new approach **Deliverables Completed:** - ✅ Working intent analysis system generating meaningful clarification questions - ✅ Integration with existing MCP tool infrastructure - ✅ Comprehensive test coverage with updated test suite - ✅ Clean removal of unused validation code ### 2025-08-14 - Phase 2: Complete Clarification Workflow + Comprehensive Testing ✅ **COMPLETED** **Milestone: Client Agent Integration and Comprehensive Test Coverage** **Key Implementation Decisions:** - **Complete Phase 2 via recommend tool extension**: Rather than create separate tools, we extended the existing `recommend` tool with `final: boolean` parameter - **Stateless workflow**: Client agents use `final: true` to indicate user has considered clarification - **Comprehensive error handling**: System gracefully degrades when AI analysis fails - **No real API usage in tests**: All 32 new tests use mocking patterns following existing conventions **Phase 2 Tasks Completed:** - [x] **Create intent clarification MCP tool** - Extended recommend tool with clarification workflow integrated - [x] **Design question presentation format** - Structured JSON response with questions, categories, reasoning, and agent instructions - [x] **Implement answer collection system** - Client agents receive clear instructions and call recommend tool with refined intent - [x] **Add skip/proceed functionality** - `final: true` parameter allows users to bypass clarification entirely - [x] **Create progress indicators** - Status fields and agent instructions provide all information needed for client progress display **Comprehensive Test Coverage Added:** - **17 new Claude service tests** - Complete coverage of `analyzeIntentForClarification()` method - JSON parsing with/without code blocks - Organizational pattern integration - Error handling and fallback scenarios - Response structure validation - **15 new recommend tool tests** - Schema validation, type signatures, workflow integration - **All tests pass** - 35 test suites, 782 total tests, 0 failures - **No real AI API usage** - Following existing test-key mocking patterns **Technical Architecture Completed:** ```typescript // Working end-to-end workflow: // Phase 1: Clarification (when final not set) recommend({ intent: "deploy web app" }) // Returns: { status: "clarification_available", questions: [...], agentInstructions: "..." } // Phase 2: Recommendations (when user provides final intent) recommend({ intent: "deploy Node.js web app with PostgreSQL", final: true }) // Proceeds with normal recommendation pipeline ``` **Integration Points Delivered:** - ✅ Extended recommend tool maintains backward compatibility - ✅ Client agents receive structured questions and clear instructions - ✅ Graceful fallback when analysis fails or no opportunities found - ✅ Seamless integration with existing recommendation pipeline **Deliverables Completed:** - ✅ Complete working clarification workflow from intent → questions → refined recommendations - ✅ Comprehensive test coverage protecting against regressions - ✅ Production-ready error handling and edge case management - ✅ Client agent integration ready for real-world usage ### 2025-08-14 - PRD #60 COMPLETION ✅ **FINAL STATUS: COMPLETED** **Project Status: Successfully Completed** The Intent Clarification and Enhancement System has been fully implemented and validated with comprehensive test coverage. All core objectives have been achieved: **✅ Implementation Complete:** - **Phase 1**: Core Intent Analysis and Question Generation - Complete with robust AI-powered analysis - **Phase 2**: Client Agent Integration and User Interface - Complete with seamless workflow integration - **Strategic Decision**: Phases 3 & 4 deferred to maintain user agency and avoid over-engineering **✅ Technical Achievements:** - **32 new comprehensive tests** added with 100% pass rate (782 total tests passing) - **Stateless architecture** with clean `final: boolean` parameter workflow - **Graceful error handling** with fallback responses when AI analysis fails - **Production-ready integration** with existing MCP tool infrastructure **✅ User Experience Goals Met:** 1. ✅ **Enhanced Intent Quality** - Users receive clarifying questions to improve deployment specifications 2. ✅ **Better Solution Relevance** - Refined intents lead to more targeted recommendations 3. ✅ **Improved User Confidence** - Clear analysis helps users understand their deployment needs 4. ✅ **Faster Time to Value** - One-round clarification reduces iteration cycles 5. ✅ **Pattern Leverage** - Organizational patterns inform question generation effectively **✅ Core Design Principles Achieved:** - **User Agency**: Users refine their own intents rather than AI doing it for them - **Learning Experience**: Clarification questions help users learn better deployment practices - **Optional Enhancement**: Users can skip clarification entirely with `final: true` - **Backward Compatibility**: Existing workflows continue to function unchanged **Final Architecture:** ```typescript // Phase 1: Intent Analysis & Questions (default behavior) recommend({ intent: "deploy web app" }) // → Returns clarification questions for user consideration // Phase 2: Final Recommendations (after user refinement) recommend({ intent: "deploy Node.js web app with PostgreSQL", final: true }) // → Proceeds directly to recommendations ``` **Production Readiness Validated:** - All tests passing across 35 test suites - Error handling tested with fallback scenarios - Client agent integration ready for deployment - No breaking changes to existing functionality The system successfully transforms vague user intents into specific, actionable deployment requirements while maintaining user control and promoting learning. **PRD #60 is officially complete and ready for production use.**

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vfarcic/dot-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server