-
Notifications
You must be signed in to change notification settings - Fork 225
Open
Description
0-parameter actions such as list_memory and list_reminders in the LocalAGI agent settings / actions tab cause tool calling to break the vast majority of the time with most models. In my testing I have only seen the tool call executed successfully once. I found a workaround for the list_memory by creating this custom action with a corresponding configuration matching the agent name + ".json" - this replicates the naming scheme used by add_memory and remove_memory actions. I don't have the appropriate development environment to test and PR a proper fix for memory.go but here is the workaround custom script for reference:
import (
"encoding/json"
"fmt"
"os"
"io"
"path/filepath"
)
var filePath string
type ListMemoryParams struct {
Confirm bool `json:"confirm"` // Dummy required parameter
}
func Init(configuration string) error {
// Store the configuration that was passed in
filePath = configuration
return nil
}
func Run(config map[string]interface{}) (string, map[string]interface{}, error) {
p := ListMemoryParams{}
b, err := json.Marshal(config)
if err != nil {
return "", map[string]interface{}{}, err
}
if err := json.Unmarshal(b, &p); err != nil {
return "", map[string]interface{}{}, err
}
memoryFile := os.Getenv("LOCALAGI_STATE_DIR") + "/memory/" + filePath
f, err := os.Open(memoryFile)
if err != nil {
return "", map[string]interface{}{}, err
}
defer f.Close()
data, err := io.ReadAll(f)
if err != nil {
return "", map[string]interface{}{}, err
}
if len(data) == 0 {
return "Memory is empty", map[string]interface{}{"count": 0}, nil
}
var items []string
if err := json.Unmarshal(data, &items); err != nil {
return "", map[string]interface{}{}, err
}
result := fmt.Sprintf("Memory contains %d item(s):\n", len(items))
for i, item := range items {
result += fmt.Sprintf("%d. %s\n", i, item)
}
return result, map[string]interface{}{
"count": len(items),
"items": items,
}, nil
}
func Definition() map[string][]string {
return map[string][]string{
"confirm": []string{
"boolean",
"Set to true to list memory contents",
},
}
}
func RequiredFields() []string {
return []string{"confirm"} // Make it required
}
Metadata
Metadata
Assignees
Labels
No labels