refactor: remove 'read' action from memory tool and agent logging
- Eliminated the 'read' action from the memory tool and related logging in the agent, streamlining the available actions to 'add', 'replace', and 'remove'. - Updated error messages and documentation to reflect the removal of the 'read' action, ensuring clarity in the API's usage.
This commit is contained in:
parent
440c244cac
commit
56ee8a5cc6
2 changed files with 3 additions and 14 deletions
|
|
@ -889,8 +889,6 @@ def _build_tool_preview(tool_name: str, args: dict, max_len: int = 40) -> str:
|
||||||
return f"~{target}: \"{args.get('old_text', '')[:20]}\""
|
return f"~{target}: \"{args.get('old_text', '')[:20]}\""
|
||||||
elif action == "remove":
|
elif action == "remove":
|
||||||
return f"-{target}: \"{args.get('old_text', '')[:20]}\""
|
return f"-{target}: \"{args.get('old_text', '')[:20]}\""
|
||||||
elif action == "read":
|
|
||||||
return f"read {target}"
|
|
||||||
return action
|
return action
|
||||||
|
|
||||||
if tool_name == "send_message":
|
if tool_name == "send_message":
|
||||||
|
|
@ -1531,8 +1529,6 @@ class AIAgent:
|
||||||
elif action == "remove":
|
elif action == "remove":
|
||||||
snippet = _trunc(args.get("old_text", ""), 20)
|
snippet = _trunc(args.get("old_text", ""), 20)
|
||||||
return f"┊ 🧠 memory -{target}: \"{snippet}\" {dur}"
|
return f"┊ 🧠 memory -{target}: \"{snippet}\" {dur}"
|
||||||
elif action == "read":
|
|
||||||
return f"┊ 🧠 memory read {target} {dur}"
|
|
||||||
elif action == "search_sessions":
|
elif action == "search_sessions":
|
||||||
query = _trunc(args.get("content", ""), 30)
|
query = _trunc(args.get("content", ""), 30)
|
||||||
return f"┊ 🧠 recall \"{query}\" {dur}"
|
return f"┊ 🧠 recall \"{query}\" {dur}"
|
||||||
|
|
|
||||||
|
|
@ -203,10 +203,6 @@ class MemoryStore:
|
||||||
|
|
||||||
return self._success_response(target, "Entry removed.")
|
return self._success_response(target, "Entry removed.")
|
||||||
|
|
||||||
def read(self, target: str) -> Dict[str, Any]:
|
|
||||||
"""Return live current entries and usage stats."""
|
|
||||||
return self._success_response(target)
|
|
||||||
|
|
||||||
def format_for_system_prompt(self, target: str) -> Optional[str]:
|
def format_for_system_prompt(self, target: str) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Return the frozen snapshot for system prompt injection.
|
Return the frozen snapshot for system prompt injection.
|
||||||
|
|
@ -328,11 +324,8 @@ def memory_tool(
|
||||||
return json.dumps({"success": False, "error": "old_text is required for 'remove' action."}, ensure_ascii=False)
|
return json.dumps({"success": False, "error": "old_text is required for 'remove' action."}, ensure_ascii=False)
|
||||||
result = store.remove(target, old_text)
|
result = store.remove(target, old_text)
|
||||||
|
|
||||||
elif action == "read":
|
|
||||||
result = store.read(target)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return json.dumps({"success": False, "error": f"Unknown action '{action}'. Use: add, replace, remove, read"}, ensure_ascii=False)
|
return json.dumps({"success": False, "error": f"Unknown action '{action}'. Use: add, replace, remove"}, ensure_ascii=False)
|
||||||
|
|
||||||
return json.dumps(result, ensure_ascii=False)
|
return json.dumps(result, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
@ -351,7 +344,7 @@ MEMORY_SCHEMA = {
|
||||||
"description": (
|
"description": (
|
||||||
"Manage persistent memory (visible in system prompt). Targets: "
|
"Manage persistent memory (visible in system prompt). Targets: "
|
||||||
"'memory' (your notes) or 'user' (user profile).\n"
|
"'memory' (your notes) or 'user' (user profile).\n"
|
||||||
"Actions: add, replace, remove, read. For replace/remove, old_text "
|
"Actions: add, replace, remove. For replace/remove, old_text "
|
||||||
"is a short unique snippet to identify the entry.\n"
|
"is a short unique snippet to identify the entry.\n"
|
||||||
"Usage indicator in system prompt shows capacity. When >80%, "
|
"Usage indicator in system prompt shows capacity. When >80%, "
|
||||||
"consolidate/replace before adding. Prefer replacing over removing.\n"
|
"consolidate/replace before adding. Prefer replacing over removing.\n"
|
||||||
|
|
@ -363,7 +356,7 @@ MEMORY_SCHEMA = {
|
||||||
"properties": {
|
"properties": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["add", "replace", "remove", "read"],
|
"enum": ["add", "replace", "remove"],
|
||||||
"description": "The action to perform."
|
"description": "The action to perform."
|
||||||
},
|
},
|
||||||
"target": {
|
"target": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue