MCPcopy Create free account
hub / github.com/compozy/agh / ResetMemory

Method ResetMemory

internal/api/core/memory.go:647–704  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

645}
646
647func (h *BaseHandlers) ResetMemory(c *gin.Context) {
648 if h.MemoryStore == nil {
649 h.respondMemoryError(c, http.StatusInternalServerError, errors.New("memory store is not configured"), nil)
650 return
651 }
652 var req contract.MemoryResetRequest
653 if err := c.ShouldBindJSON(&req); err != nil && !errors.Is(err, io.EOF) {
654 h.respondMemoryError(
655 c,
656 http.StatusBadRequest,
657 fmt.Errorf("%s: decode memory reset request: %w", h.transportName(), err),
658 nil,
659 )
660 return
661 }
662 if !req.Confirm {
663 c.JSON(http.StatusOK, contract.MemoryResetResponse{
664 ResetAt: h.nowUTC(),
665 DerivedOnly: req.DerivedOnly,
666 })
667 return
668 }
669 if !req.DerivedOnly {
670 err := NewMemoryValidationError(errors.New("only derived memory reset is supported in Slice 1"))
671 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
672 return
673 }
674 selector, err := h.resolveMemorySelector(c.Request.Context(), memorySelector{
675 Scope: req.Scope,
676 WorkspaceID: req.WorkspaceID,
677 AgentName: req.AgentName,
678 AgentTier: req.AgentTier,
679 }, false)
680 if err != nil {
681 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
682 return
683 }
684 selector.Scope = defaultMemorySelectorScope(selector)
685 store, err := h.memoryRecallStoreForSelector(c.Request.Context(), selector)
686 if err != nil {
687 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
688 return
689 }
690 result, err := store.ResetDerived(c.Request.Context(), memcontract.ReindexOptions{
691 Scope: selector.Scope,
692 Workspace: selector.Workspace,
693 })
694 if err != nil {
695 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
696 return
697 }
698 c.JSON(http.StatusOK, contract.MemoryResetResponse{
699 ResetAt: result.ResetAt.UTC(),
700 DerivedOnly: true,
701 DeletedRows: result.DeletedRows,
702 DeletedFiles: 0,
703 })
704}

Callers

nothing calls this directly

Calls 10

respondMemoryErrorMethod · 0.95
transportNameMethod · 0.95
nowUTCMethod · 0.95
resolveMemorySelectorMethod · 0.95
NewMemoryValidationErrorFunction · 0.85
StatusForMemoryErrorFunction · 0.85
ResetDerivedMethod · 0.80
IsMethod · 0.45

Tested by

no test coverage detected