Skip to content

Add memory_save tool #237

@theantichris

Description

@theantichris

Summary

Add a memory_save tool that allows the LLM to persist important information to Ghost's memory system. Follows the same tool.Tool interface pattern as search.go.

Details

New files:

  • internal/tool/memory_save.go
  • internal/tool/memory_save_test.go

Type:

type MemorySave struct {
    Store *memory.Store
}

Tool definition:

  • Name: memory_save
  • Description: "save important information to persistent memory for future reference"
  • Parameters:
    • content (string, required): the information to save
    • target (string, optional): "daily" (default) or "long_term"

Execute:

  • Parse args JSON (same pattern as search.go)
  • Route to Store.SaveToDaily() or Store.SaveToLongTerm() based on target
  • Return confirmation: "Saved to daily log (2026-02-07.md)" or "Saved to long-term memory (MEMORY.md)"

Errors:

  • ErrMemorySaveArgs — failed to parse arguments
  • ErrMemorySaveFail — save operation failed
  • ErrInvalidTarget — target not "daily" or "long_term"

Testing:

  • Table-driven tests following search_test.go pattern
  • Use real memory.Store with temp dir and mock EmbedFunc

Note: This tool is not registered in the registry yet — that happens in the integration issue.

Dependencies

Acceptance Criteria

  • Implements tool.Tool interface (Definition() + Execute())
  • Saves to daily log by default
  • Saves to MEMORY.md when target is "long_term"
  • Returns clear confirmation message
  • Proper error handling for invalid args and save failures
  • Table-driven tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions