AgentSkillsCN

Conversational Query

通过对话流、斜杠命令与苏格拉底式提问,实现对话式查询处理

SKILL.md
--- frontmatter
description: Conversational query handling with dialog flow, slash commands, and Socratic questioning

CARF Conversational Query Skill

Purpose

Handle multi-turn conversational query flows with slash commands, Socratic questioning, and context gathering before analysis execution.

When to Use

  • Implementing dialog-flow query experience
  • Adding slash command handling to chat
  • Building Socratic questioning mode
  • Managing conversation context

Slash Commands Reference

CommandActionBackend Endpoint
/questionStart Socratic questioning modeLocal LLM call
/queryExecute analysis queryPOST /query
/analysisShow last analysis snapshotLocal state
/historyOpen analysis history panellocalStorage or future API
/helpShow available commandsStatic content

Implementation Pattern

Command Detection

typescript
const parseSlashCommand = (input: string): SlashCommand | null => {
  const match = input.match(/^\/(\w+)\s*(.*)/);
  if (!match) return null;
  
  const [, command, args] = match;
  return { command, args };
};

Socratic Mode Flow

code
User: /question
Bot: Let me help improve your analysis:

1. Context: Your current confidence is 72%.
   Question: Can you describe the business domain more specifically?

2. Data: I detected 3 confounders.
   Question: Are there industry-specific factors not captured?

3. Variables: The causal direction assumes X→Y.
   Question: Could Y→X also be plausible?

[User answers each question, updating context]

Required Frontend State

typescript
interface ConversationState {
  mode: 'normal' | 'socratic' | 'dialog-flow';
  currentStep?: number;
  gatheredContext: {
    domain?: string;
    variables?: string[];
    dataset?: string;
    hypothesis?: string;
  };
  lastAnalysis?: QueryResponse;
}

Backend Integration

Existing Endpoints

  • POST /query - Main analysis (use for /query command)
  • GET /scenarios - Demo scenarios (use for context suggestions)
  • GET /health - System status

API Gaps for Phase 7 (Planned)

EndpointPurposeStatus
POST /what-ifCounterfactual simulationNOT IMPLEMENTED
GET /sessionsAnalysis historyNOT IMPLEMENTED
POST /sessions/{id}Save analysis sessionNOT IMPLEMENTED

Socratic Prompts Library

Quantify Uncertainty

code
Your confidence is {confidence}%.
What additional data would increase certainty?
- [ ] More samples from similar domains
- [ ] External validation data
- [ ] Expert review

Probe Complexity

code
I identified {n} confounders: {confounders}.
Are there industry-specific factors not captured?

Challenge Assumptions

code
The causal model assumes {treatment} → {outcome}.
Could the reverse direction be plausible?

Suggest Improvements

code
Adding {n} more samples could reduce epistemic uncertainty by ~{reduction}%.
Would you like to:
- [ ] Upload additional data
- [ ] Generate synthetic test data
- [ ] Proceed with current confidence

Troubleshooting

Command Not Recognized

  • Check for leading whitespace in input
  • Verify command is lowercase
  • Check for typos in command name

Socratic Mode Not Advancing

  • Ensure user input is captured before next step
  • Check gatheredContext is being updated
  • Verify LLM connection for dynamic questions