Revert "feat(agent): support global memory inheritance in isolated agents"
This reverts commit 8106d61011.
This commit is contained in:
parent
8106d61011
commit
31906c8f19
2 changed files with 10 additions and 30 deletions
|
|
@ -86,7 +86,7 @@ func NewContextBuilder(workspace string, baseWorkspace string) *ContextBuilder {
|
||||||
workspace: workspace,
|
workspace: workspace,
|
||||||
baseWorkspace: baseWorkspace,
|
baseWorkspace: baseWorkspace,
|
||||||
skillsLoader: skills.NewSkillsLoader(workspace, baseWorkspace, globalSkillsDir, builtinSkillsDir, nil, false),
|
skillsLoader: skills.NewSkillsLoader(workspace, baseWorkspace, globalSkillsDir, builtinSkillsDir, nil, false),
|
||||||
memory: NewMemoryStore(workspace, baseWorkspace),
|
memory: NewMemoryStore(workspace),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,13 @@ import (
|
||||||
// - Daily notes: memory/YYYYMM/YYYYMMDD.md
|
// - Daily notes: memory/YYYYMM/YYYYMMDD.md
|
||||||
type MemoryStore struct {
|
type MemoryStore struct {
|
||||||
workspace string
|
workspace string
|
||||||
baseWorkspace string
|
|
||||||
memoryDir string
|
memoryDir string
|
||||||
memoryFile string
|
memoryFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMemoryStore creates a new MemoryStore with the given workspace path.
|
// NewMemoryStore creates a new MemoryStore with the given workspace path.
|
||||||
// It also takes an optional baseWorkspace for global memory inheritance.
|
|
||||||
// It ensures the memory directory exists.
|
// It ensures the memory directory exists.
|
||||||
func NewMemoryStore(workspace string, baseWorkspace string) *MemoryStore {
|
func NewMemoryStore(workspace string) *MemoryStore {
|
||||||
memoryDir := filepath.Join(workspace, "memory")
|
memoryDir := filepath.Join(workspace, "memory")
|
||||||
memoryFile := filepath.Join(memoryDir, "MEMORY.md")
|
memoryFile := filepath.Join(memoryDir, "MEMORY.md")
|
||||||
|
|
||||||
|
|
@ -38,7 +36,6 @@ func NewMemoryStore(workspace string, baseWorkspace string) *MemoryStore {
|
||||||
|
|
||||||
return &MemoryStore{
|
return &MemoryStore{
|
||||||
workspace: workspace,
|
workspace: workspace,
|
||||||
baseWorkspace: baseWorkspace,
|
|
||||||
memoryDir: memoryDir,
|
memoryDir: memoryDir,
|
||||||
memoryFile: memoryFile,
|
memoryFile: memoryFile,
|
||||||
}
|
}
|
||||||
|
|
@ -134,35 +131,18 @@ func (ms *MemoryStore) GetRecentDailyNotes(days int) string {
|
||||||
|
|
||||||
// GetMemoryContext returns formatted memory context for the agent prompt.
|
// GetMemoryContext returns formatted memory context for the agent prompt.
|
||||||
// Includes long-term memory and recent daily notes.
|
// Includes long-term memory and recent daily notes.
|
||||||
// If baseWorkspace is set, it also includes global memory context.
|
|
||||||
func (ms *MemoryStore) GetMemoryContext() string {
|
func (ms *MemoryStore) GetMemoryContext() string {
|
||||||
longTerm := ms.ReadLongTerm()
|
longTerm := ms.ReadLongTerm()
|
||||||
recentNotes := ms.GetRecentDailyNotes(3)
|
recentNotes := ms.GetRecentDailyNotes(3)
|
||||||
|
|
||||||
var globalLongTerm string
|
if longTerm == "" && recentNotes == "" {
|
||||||
if ms.baseWorkspace != "" && ms.baseWorkspace != ms.workspace {
|
|
||||||
globalFile := filepath.Join(ms.baseWorkspace, "memory", "MEMORY.md")
|
|
||||||
if data, err := os.ReadFile(globalFile); err == nil {
|
|
||||||
globalLongTerm = string(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if longTerm == "" && recentNotes == "" && globalLongTerm == "" {
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
|
|
||||||
if globalLongTerm != "" {
|
|
||||||
sb.WriteString("## Global Memory\n\n")
|
|
||||||
sb.WriteString(globalLongTerm)
|
|
||||||
if longTerm != "" || recentNotes != "" {
|
|
||||||
sb.WriteString("\n\n---\n\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if longTerm != "" {
|
if longTerm != "" {
|
||||||
sb.WriteString("## Session Memory\n\n")
|
sb.WriteString("## Long-term Memory\n\n")
|
||||||
sb.WriteString(longTerm)
|
sb.WriteString(longTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue