reset_session
Clear chat history while maintaining the session ID to start fresh when switching tasks. Ask the user before resetting.
Instructions
Reset a session's chat history (keep same session ID). Use for a clean slate when the task changes; ask the user before resetting.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | The session ID to reset |
Implementation Reference
- src/tools/handlers.ts:283-325 (handler)The main handler function for the reset_session tool. Retrieves the session by ID, calls session.reset() to clear its chat history, and returns success/error status./** * Handle reset_session tool */ async handleResetSession(args: { session_id: string }): Promise< ToolResult<{ status: string; message: string; session_id: string }> > { const { session_id } = args; log.info(`🔧 [TOOL] reset_session called`); log.info(` Session ID: ${session_id}`); try { const session = this.sessionManager.getSession(session_id); if (!session) { log.warning(`⚠️ [TOOL] Session ${session_id} not found`); return { success: false, error: `Session ${session_id} not found`, }; } await session.reset(); log.success(`✅ [TOOL] reset_session completed`); return { success: true, data: { status: "success", message: `Session ${session_id} reset successfully`, session_id, }, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log.error(`❌ [TOOL] reset_session failed: ${errorMessage}`); return { success: false, error: errorMessage, }; } }
- Tool definition including name, description, and input schema requiring 'session_id' string.{ name: "reset_session", description: "Reset a session's chat history (keep same session ID). " + "Use for a clean slate when the task changes; ask the user before resetting.", inputSchema: { type: "object", properties: { session_id: { type: "string", description: "The session ID to reset", }, }, required: ["session_id"], }, }, ];
- src/index.ts:242-246 (registration)Dispatches calls to the reset_session tool to the ToolHandlers.handleResetSession method in the main MCP server request handler.case "reset_session": result = await this.toolHandlers.handleResetSession( args as { session_id: string } ); break;