108 lines
5.9 KiB
Python
108 lines
5.9 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
MEMORY_SEARCH = {
|
|
"name": "memory_search",
|
|
"description": "Search accessible Memory Gateway records for the current user/agent context.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"query": {"type": "string", "description": "Search query. Must not be empty."},
|
|
"user_id": {"type": "string", "description": "Memory Gateway user id."},
|
|
"agent_id": {"type": "string", "description": "Calling agent id, for ACL and namespace routing."},
|
|
"workspace_id": {"type": "string", "description": "Optional workspace/project id."},
|
|
"session_id": {"type": "string", "description": "Optional session id for session-scoped context."},
|
|
"namespaces": {"type": "array", "items": {"type": "string"}, "description": "Optional namespace filters."},
|
|
"memory_types": {"type": "array", "items": {"type": "string"}, "description": "Optional memory type filters."},
|
|
"tags": {"type": "array", "items": {"type": "string"}, "description": "Optional tag filters."},
|
|
"limit": {"type": "integer", "description": "Maximum result count.", "default": 5},
|
|
},
|
|
"required": ["query", "user_id", "agent_id"],
|
|
},
|
|
}
|
|
|
|
MEMORY_APPEND_EPISODE = {
|
|
"name": "memory_append_episode",
|
|
"description": "Append a safe summarized candidate episode. Does not save full raw conversation or directly promote long-term memory.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"content": {"type": "string", "description": "Safe summarized episode content. Do not pass raw transcripts."},
|
|
"episode_summary": {"type": "string", "description": "Optional prebuilt summary. Used instead of content when provided."},
|
|
"user_id": {"type": "string", "description": "Memory Gateway user id."},
|
|
"agent_id": {"type": "string", "description": "Calling agent id."},
|
|
"workspace_id": {"type": "string", "description": "Optional workspace/project id."},
|
|
"session_id": {"type": "string", "description": "Current session id."},
|
|
"tags": {"type": "array", "items": {"type": "string"}, "description": "Optional tags."},
|
|
"source": {"type": "string", "description": "Source label.", "default": "conversation"},
|
|
},
|
|
"required": ["content", "user_id", "agent_id", "session_id"],
|
|
},
|
|
}
|
|
|
|
MEMORY_COMMIT_SESSION = {
|
|
"name": "memory_commit_session",
|
|
"description": "Commit a session through Memory Gateway and EverMemOS. Promotes only what consolidation accepts.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"user_id": {"type": "string", "description": "Memory Gateway user id."},
|
|
"agent_id": {"type": "string", "description": "Calling agent id."},
|
|
"workspace_id": {"type": "string", "description": "Optional workspace/project id."},
|
|
"session_id": {"type": "string", "description": "Session id to commit."},
|
|
"promote": {"type": "boolean", "description": "Whether promotion is allowed.", "default": True},
|
|
"min_importance": {"type": "number", "description": "Minimum importance threshold.", "default": 0.6},
|
|
},
|
|
"required": ["user_id", "agent_id", "session_id"],
|
|
},
|
|
}
|
|
|
|
MEMORY_UPSERT = {
|
|
"name": "memory_upsert",
|
|
"description": "High-risk direct memory write. Use only for stable, concise, user-approved long-term memory; do not call automatically.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"user_id": {"type": "string", "description": "Memory Gateway user id."},
|
|
"agent_id": {"type": "string", "description": "Calling agent id."},
|
|
"workspace_id": {"type": "string", "description": "Optional workspace/project id."},
|
|
"namespace": {"type": "string", "description": "Optional explicit namespace, e.g. user/{user_id}/long_term."},
|
|
"memory_type": {"type": "string", "description": "Memory type, e.g. preference, decision, fact, procedure."},
|
|
"content": {"type": "string", "description": "Stable memory content. Do not pass full raw conversation."},
|
|
"summary": {"type": "string", "description": "Optional concise summary."},
|
|
"tags": {"type": "array", "items": {"type": "string"}, "description": "Optional tags."},
|
|
"importance": {"type": "number", "description": "Importance score 0..1.", "default": 0.5},
|
|
"confidence": {"type": "number", "description": "Confidence score 0..1.", "default": 0.8},
|
|
"visibility": {"type": "string", "description": "Memory visibility.", "default": "private"},
|
|
},
|
|
"required": ["user_id", "agent_id", "content", "memory_type"],
|
|
},
|
|
}
|
|
|
|
MEMORY_FEEDBACK = {
|
|
"name": "memory_feedback",
|
|
"description": "Send quality feedback for an existing memory record.",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"memory_id": {"type": "string", "description": "Memory id to mark."},
|
|
"user_id": {"type": "string", "description": "Memory Gateway user id."},
|
|
"agent_id": {"type": "string", "description": "Calling agent id."},
|
|
"workspace_id": {"type": "string", "description": "Optional workspace/project id."},
|
|
"session_id": {"type": "string", "description": "Optional session id."},
|
|
"feedback": {"type": "string", "description": "Feedback, e.g. confirm, correct, delete, reject, incorrect, duplicate, outdated."},
|
|
"comment": {"type": "string", "description": "Optional feedback comment."},
|
|
},
|
|
"required": ["memory_id", "user_id", "agent_id", "feedback"],
|
|
},
|
|
}
|
|
|
|
TOOL_SCHEMAS = {
|
|
"memory_search": MEMORY_SEARCH,
|
|
"memory_append_episode": MEMORY_APPEND_EPISODE,
|
|
"memory_commit_session": MEMORY_COMMIT_SESSION,
|
|
"memory_upsert": MEMORY_UPSERT,
|
|
"memory_feedback": MEMORY_FEEDBACK,
|
|
}
|
|
|