log-query
Analyze and log unusual or noteworthy conversation interactions based on probability classifications for unexpected patterns, technical issues, and critical edge cases.
Instructions
Conversation Variation analysis
Continuously monitor our conversation and automatically log unusual or noteworthy interactions based on the following criteria:
1. Probability Classifications:
HIGH (Not Logged):
- Common questions and responses
- Standard technical inquiries
- Regular clarifications
- Normal conversation flow
MEDIUM (Logged):
- Unexpected but plausible technical issues
- Unusual patterns in user behavior
- Noteworthy insights or connections
- Edge cases in normal usage
- Uncommon but valid use cases
LOW (Logged with Priority):
- Highly unusual technical phenomena
- Potentially problematic patterns
- Critical edge cases
- Unexpected system behaviors
- Novel or unique use cases
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_summary | Yes | Summary of interaction context | |
| interaction_type | Yes | Type of interaction being monitored | |
| message_content | Yes | The user's message content | |
| probability_class | Yes | Classification of interaction probability | |
| reasoning | Yes | Explanation for the probability classification | |
| response_content | Yes | The system's response content | |
| session_id | Yes | Unique identifier for the chat session. Format: <date>_<user>_<sequence> Example: 20240124_u1_001 Components: - date: YYYYMMDD - user: 'u' + user number - sequence: 3-digit sequential number Valid examples: - 20240124_u1_001 - 20240124_u1_002 - 20240125_u2_001 | |
| user_id | Yes | Identifier for the user |
Implementation Reference
- src/mcp_variance_log/server.py:329-354 (handler)Handler for log-query tool: extracts parameters from arguments and calls LogDatabase.add_log() to store the interaction log.elif name == "log-query": # Existing log-query logic session_id = arguments.get("session_id", "") user_id = arguments.get("user_id", "") interaction_type = arguments.get("interaction_type", "") probability_class = arguments.get("probability_class", "") message_content = arguments.get("message_content", "") response_content = arguments.get("response_content", "") context_summary = arguments.get("context_summary", "") reasoning = arguments.get("reasoning", "") success = db.add_log( session_id=session_id, user_id=user_id, interaction_type=interaction_type, probability_class=probability_class, message_content=message_content, response_content=response_content, context_summary=context_summary, reasoning=reasoning ) return [types.TextContent( type="text", text="Log entry added successfully" if success else "Failed to add log entry" )],
- JSON Schema defining the input parameters for the log-query tool, including session_id, user_id, interaction_type, probability_class, message_content, response_content, context_summary, and reasoning.inputSchema={ "type": "object", "properties": { "session_id": { "type": "string", "description": """Unique identifier for the chat session. Format: <date>_<user>_<sequence> Example: 20240124_u1_001 Components: - date: YYYYMMDD - user: 'u' + user number - sequence: 3-digit sequential number Valid examples: - 20240124_u1_001 - 20240124_u1_002 - 20240125_u2_001""", "pattern": "^\\d{8}_u\\d+_\\d{3}$" # Regex pattern to validate format }, "user_id": { "type": "string", "description": "Identifier for the user" }, "interaction_type": { "type": "string", "description": "Type of interaction being monitored" }, "probability_class": { "type": "string", "enum": ["HIGH", "MEDIUM", "LOW"], "description": "Classification of interaction probability" }, "message_content": { "type": "string", "description": "The user's message content" }, "response_content": { "type": "string", "description": "The system's response content" }, "context_summary": { "type": "string", "description": "Summary of interaction context" }, "reasoning": { "type": "string", "description": "Explanation for the probability classification" } }, "required": [ "session_id", "user_id", "interaction_type", "probability_class", "message_content", "response_content", "context_summary", "reasoning" ]
- src/mcp_variance_log/server.py:31-118 (registration)Registration of the log-query tool within the @server.list_tools() handler, specifying name, description, and input schema.name="log-query", description=""" Conversation Variation analysis Continuously monitor our conversation and automatically log unusual or noteworthy interactions based on the following criteria: 1. Probability Classifications: HIGH (Not Logged): - Common questions and responses - Standard technical inquiries - Regular clarifications - Normal conversation flow MEDIUM (Logged): - Unexpected but plausible technical issues - Unusual patterns in user behavior - Noteworthy insights or connections - Edge cases in normal usage - Uncommon but valid use cases LOW (Logged with Priority): - Highly unusual technical phenomena - Potentially problematic patterns - Critical edge cases - Unexpected system behaviors - Novel or unique use cases """, inputSchema={ "type": "object", "properties": { "session_id": { "type": "string", "description": """Unique identifier for the chat session. Format: <date>_<user>_<sequence> Example: 20240124_u1_001 Components: - date: YYYYMMDD - user: 'u' + user number - sequence: 3-digit sequential number Valid examples: - 20240124_u1_001 - 20240124_u1_002 - 20240125_u2_001""", "pattern": "^\\d{8}_u\\d+_\\d{3}$" # Regex pattern to validate format }, "user_id": { "type": "string", "description": "Identifier for the user" }, "interaction_type": { "type": "string", "description": "Type of interaction being monitored" }, "probability_class": { "type": "string", "enum": ["HIGH", "MEDIUM", "LOW"], "description": "Classification of interaction probability" }, "message_content": { "type": "string", "description": "The user's message content" }, "response_content": { "type": "string", "description": "The system's response content" }, "context_summary": { "type": "string", "description": "Summary of interaction context" }, "reasoning": { "type": "string", "description": "Explanation for the probability classification" } }, "required": [ "session_id", "user_id", "interaction_type", "probability_class", "message_content", "response_content", "context_summary", "reasoning" ] }, ),
- Helper method LogDatabase.add_log() that performs the SQL INSERT into the chat_monitoring table to persist the log entry.def add_log(self, session_id: str, user_id: str, interaction_type: str, probability_class: str, message_content: str, response_content: str, context_summary: str, reasoning: str) -> bool: """ Add a new log entry to the database. Args: session_id (str): Unique identifier for the chat session user_id (str): Identifier for the user interaction_type (str): Type of interaction being monitored probability_class (str): Classification (HIGH, MEDIUM, LOW) message_content (str): The user's message content response_content (str): The system's response content context_summary (str): Summary of interaction context reasoning (str): Explanation for the classification Returns: bool: True if successful, False otherwise """ try: with sqlite3.connect(self.db_path) as conn: cursor = conn.cursor() cursor.execute(''' INSERT INTO chat_monitoring ( session_id, user_id, interaction_type, probability_class, message_content, response_content, context_summary, reasoning ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ''', (session_id, user_id, interaction_type, probability_class, message_content, response_content, context_summary, reasoning)) return True except Exception as e: print(f"Error adding log: {e}") return False