Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025

This PR implements intelligent parameter elicitation and sampling functionality for Kusto operations when cluster URIs or databases are unclear or missing.

Problem

Previously, all Kusto operations required explicit cluster_uri and database parameters. When these were missing or unclear, users would get generic error messages without guidance on available options or intelligent defaults.

Solution

Added a comprehensive elicitation and sampling system that:

🎯 Elicitation: Provides helpful guidance when parameters are missing

# Before: Generic error
kusto_query("StormEvents | take 5", None)  # TypeError

# After: Helpful guidance with available options
kusto_query_with_elicitation("StormEvents | take 5")
# KustoElicitationError: No cluster URI provided. Available clusters: 
# 'https://prod.kusto.windows.net', 'https://samples.kusto.windows.net'

🧠 Sampling: Intelligent parameter selection based on context

# Context-aware cluster selection
kusto_query_with_elicitation("show me sample data")  # Prefers clusters with "sample" in description

# Database inference from query content  
kusto_query_with_elicitation("TestDB.MyTable | take 10")  # Prefers "TestDB" database

Key Features

  • New Exception Classes: KustoElicitationError provides structured information for user prompting
  • Context-Based Sampling: Analyzes query content to make intelligent parameter choices
  • Graceful Fallbacks: Tries sampling first, then elicitation if needed
  • Rich Error Messages: Lists available options and suggests specific values
  • Backward Compatibility: Existing functions unchanged

New Tools

  • kusto_query_with_elicitation(): Execute queries with parameter elicitation support
  • kusto_sample_data_with_elicitation(): Sample table data with parameter elicitation
  • kusto_explore_with_elicitation(): Explore databases with parameter elicitation

Implementation Details

The system handles both scenarios from the issue:

  1. Missing cluster/database: Elicits user interaction with helpful guidance
  2. Multiple options available: Uses context-based sampling to intelligently pick one

Sampling logic includes:

  • Query content analysis (e.g., "sample" queries → sample clusters)
  • Database name hints (e.g., "DB.Table" → DB database)
  • Default service preferences
  • Random sampling as fallback

Testing

Added 18 comprehensive tests covering:

  • Cluster sampling with various scenarios
  • Database sampling with context awareness
  • Elicitation error handling
  • Tool function integration
  • Edge cases and error conditions

All existing tests continue to pass, ensuring backward compatibility.

Fixes #54.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • demo.kusto.windows.net
    • Triggering command: python manual_test_elicitation.py (dns block)
  • production.kusto.windows.net
    • Triggering command: python manual_test_elicitation.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Use sampling and elicitation when unclear Implement elicitation and sampling for Kusto cluster and database selection Aug 20, 2025
Copilot finished work on behalf of danield137 August 20, 2025 18:15
@Copilot Copilot AI requested a review from danield137 August 20, 2025 18:15
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.

Use sampling and elicitation when unclear
2 participants