skills/session-management/SKILL.md
# Session Management ## Capability Manages voice call sessions with unique session IDs, conversation history, context preservation across turns, and automatic cleanup on disconnect or timeout. ## MCP Tools | Tool | Input Schema | Output | Rate Limit | |------|-------------|--------|------------| | `session.create` | `z.object({ callSid: z.string(), config: SessionConfig })` | `{ sessionId: string, createdAt: string }` | 100 RPM | | `session.get` | `z.object({ sessionId: z.string() })` | `{ s
npx skillsauth add reaatech/voice-agent-kit skills/session-managementInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Manages voice call sessions with unique session IDs, conversation history, context preservation across turns, and automatic cleanup on disconnect or timeout.
| Tool | Input Schema | Output | Rate Limit |
|------|-------------|--------|------------|
| session.create | z.object({ callSid: z.string(), config: SessionConfig }) | { sessionId: string, createdAt: string } | 100 RPM |
| session.get | z.object({ sessionId: z.string() }) | { session: Session | null } | 1000 RPM |
| session.update | z.object({ sessionId: z.string(), updates: Partial<Session> }) | { updated: boolean, session: Session } | 1000 RPM |
| session.close | z.object({ sessionId: z.string(), reason: z.string().optional() }) | { closed: boolean, duration: number } | 100 RPM |
| session.cleanup | z.object({ olderThan: z.number() }) | { cleaned: number } | 10 RPM |
{
"name": "session.create",
"arguments": {
"callSid": "CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"config": {
"mcpEndpoint": "http://mcp-server:8080",
"sttProvider": "deepgram",
"ttsProvider": "deepgram",
"ttl": 3600
}
}
}
{
"sessionId": "sess-abc123-def456",
"createdAt": "2026-04-15T23:00:00Z"
}
{
"name": "session.update",
"arguments": {
"sessionId": "sess-abc123-def456",
"updates": {
"turns": [
{
"turnId": "turn-001",
"userUtterance": "I need to reset my password",
"agentResponse": "I can help with that. What's your email?",
"timestamp": "2026-04-15T23:00:05Z",
"latencyMs": 720
}
]
}
}
}
{
"updated": true,
"session": {
"sessionId": "sess-abc123-def456",
"callSid": "CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"turns": [
{
"turnId": "turn-001",
"userUtterance": "I need to reset my password",
"agentResponse": "I can help with that. What's your email?",
"timestamp": "2026-04-15T23:00:05Z",
"latencyMs": 720
}
],
"lastActivityAt": "2026-04-15T23:00:05Z"
}
}
{
"name": "session.get",
"arguments": {
"sessionId": "sess-abc123-def456"
}
}
{
"session": {
"sessionId": "sess-abc123-def456",
"callSid": "CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"mcpEndpoint": "http://mcp-server:8080",
"sttProvider": "deepgram",
"ttsProvider": "deepgram",
"turns": [
{
"turnId": "turn-001",
"userUtterance": "I need to reset my password",
"agentResponse": "I can help with that. What's your email?",
"timestamp": "2026-04-15T23:00:05Z",
"latencyMs": 720
}
],
"createdAt": "2026-04-15T23:00:00Z",
"lastActivityAt": "2026-04-15T23:00:05Z",
"metadata": {}
}
}
{
"name": "session.close",
"arguments": {
"sessionId": "sess-abc123-def456",
"reason": "call_completed"
}
}
{
"closed": true,
"duration": 125000
}
| Failure | Cause | Recovery | |---------|-------|----------| | Session not found | Invalid sessionId or expired | Return null, suggest creating new session | | Session already closed | Duplicate close call | Return error, log warning | | TTL expired | Session inactive too long | Auto-cleanup, return not found | | Storage failure | Database/connection error | Retry with backoff, use in-memory fallback | | Concurrent updates | Race condition | Use optimistic locking or last-write-wins |
interface Session {
sessionId: string; // UUID
callSid: string; // Twilio Call SID
mcpEndpoint: string; // MCP server URL
sttProvider: string; // STT provider name
ttsProvider: string; // TTS provider name
turns: Turn[]; // Conversation history
createdAt: Date;
lastActivityAt: Date;
ttl: number; // Time-to-live in seconds
metadata: Record<string, unknown>; // Custom data
status: 'active' | 'closed';
}
interface Turn {
turnId: string;
userUtterance: string;
agentResponse: string;
timestamp: Date;
latencyMs: number;
toolCalls?: ToolCall[];
}
# voice-agent-kit.config.ts
session:
# Conversation history settings
history:
maxTurns: 20 # Keep last 20 turns
maxTokens: 4000 # Or 4000 tokens (whichever is smaller)
includeToolCalls: true # Include tool call details
# TTL settings
ttl: 3600 # 1 hour default
cleanupInterval: 300 # Check every 5 minutes
# Storage backend
storage:
type: 'memory' # or 'redis', 'postgres'
connectionString: '${SESSION_STORAGE_URL}'
The session manager maintains conversation context for MCP requests:
// Build context from session history
const context: Array<{ role: string; content: string }> = [];
for (const turn of session.turns.slice(-5)) {
context.push({ role: 'user', content: turn.userUtterance });
context.push({ role: 'assistant', content: turn.agentResponse });
}
// Include in MCP request
const mcpRequest = {
utterance: currentUtterance,
context: context,
sessionId: session.sessionId
};
| Metric | Type | Description |
|--------|------|-------------|
| voice.session.active | Gauge | Current active sessions |
| voice.session.created | Counter | Sessions created |
| voice.session.closed | Counter | Sessions closed |
| voice.session.timeout | Counter | Sessions expired by TTL |
| voice.session.turn_count | Histogram | Turns per session |
| voice.session.duration_seconds | Histogram | Session duration |
| Span | Attributes |
|------|------------|
| voice.session.create | call_sid, mcp_endpoint, stt_provider |
| voice.session.update | session_id, turn_count |
| voice.session.close | session_id, reason, duration |
| voice.session.cleanup | sessions_cleaned, older_than |
tools
# Twilio Media Streams ## Capability Handles Twilio Media Streams WebSocket connections for real-time bidirectional audio communication, parsing inbound messages, encoding outbound audio, and managing call lifecycle events. ## MCP Tools | Tool | Input Schema | Output | Rate Limit | |------|-------------|--------|------------| | `twilio.handleStart` | `z.object({ message: z.object({ event: z.literal('start'), callSid: z.string(), streamSid: z.string(), format: z.string(), tracks: z.array(z.st
tools
# TTS Provider Interface ## Capability Provides a unified interface for text-to-speech (TTS) providers, enabling streaming audio synthesis with first-byte latency tracking, voice selection, and output format conversion. ## MCP Tools | Tool | Input Schema | Output | Rate Limit | |------|-------------|--------|------------| | `tts.synthesize` | `z.object({ text: z.string(), config: z.object({ provider: z.string(), voice: z.string().optional(), speed: z.number().optional() }) })` | `{ chunks: A
tools
# Telephony Lifecycle ## Capability Manages the complete lifecycle of voice calls from TwiML webhook initiation through call completion, including call connect, transfer, conference, and disconnect handling with proper session cleanup. ## MCP Tools | Tool | Input Schema | Output | Rate Limit | |------|-------------|--------|------------| | `telephony.generateTwiML` | `z.object({ sessionId: z.string(), wsUrl: z.string().url() })` | `{ twiml: string }` | 100 RPM | | `telephony.handleConnect` |
tools
# STT Provider Interface ## Capability Provides a unified interface for speech-to-text (STT) providers, enabling real-time streaming transcription with interim results, endpoint detection, and automatic reconnection handling. ## MCP Tools | Tool | Input Schema | Output | Rate Limit | |------|-------------|--------|------------| | `stt.connect` | `z.object({ provider: z.enum(['deepgram', 'aws-transcribe', 'google-cloud']), config: z.object({ apiKey: z.string().optional(), sampleRate: z.number