MCPcopy Create free account
hub / github.com/astercloud/aster / ClearWorkingMemory

Method ClearWorkingMemory

server/handlers/memory.go:341–388  ·  view source on GitHub ↗

ClearWorkingMemory clears working memory

(c *gin.Context)

Source from the content-addressed store, hash-verified

339
340// ClearWorkingMemory clears working memory
341func (h *MemoryHandler) ClearWorkingMemory(c *gin.Context) {
342 ctx := c.Request.Context()
343 sessionID := c.Query("session_id")
344 agentID := c.Query("agent_id")
345
346 records, err := (*h.store).List(ctx, "working_memory")
347 if err != nil {
348 c.JSON(http.StatusInternalServerError, gin.H{
349 "success": false,
350 "error": gin.H{
351 "code": "internal_error",
352 "message": "Failed to list working memory: " + err.Error(),
353 },
354 })
355 return
356 }
357
358 deleted := 0
359 for _, record := range records {
360 var memory WorkingMemoryRecord
361 if err := store.DecodeValue(record, &memory); err != nil {
362 continue
363 }
364
365 // 过滤
366 if sessionID != "" && memory.SessionID != sessionID {
367 continue
368 }
369 if agentID != "" && memory.AgentID != agentID {
370 continue
371 }
372
373 if err := (*h.store).Delete(ctx, "working_memory", memory.ID); err == nil {
374 deleted++
375 }
376 }
377
378 logging.Info(ctx, "working_memory.cleared", map[string]any{
379 "deleted_count": deleted,
380 })
381
382 c.JSON(http.StatusOK, gin.H{
383 "success": true,
384 "data": gin.H{
385 "deleted_count": deleted,
386 },
387 })
388}
389
390// CreateSemanticMemory creates semantic memory
391func (h *MemoryHandler) CreateSemanticMemory(c *gin.Context) {

Callers

nothing calls this directly

Calls 8

DecodeValueFunction · 0.92
InfoFunction · 0.92
JSONMethod · 0.80
ContextMethod · 0.65
QueryMethod · 0.65
ListMethod · 0.65
ErrorMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected