feat:记忆修改隔离
This commit is contained in:
parent
598d425c28
commit
7755164df5
@ -182,11 +182,7 @@ fn scope_key_from_context(context: &ToolContext) -> Result<String, ToolResult> {
|
||||
.channel_name
|
||||
.as_deref()
|
||||
.ok_or_else(|| error_result("memory_manage requires channel_name in tool context"))?;
|
||||
let sender_id = context
|
||||
.sender_id
|
||||
.as_deref()
|
||||
.ok_or_else(|| error_result("memory_manage requires sender_id in tool context"))?;
|
||||
Ok(format!("{}:{}", channel_name, sender_id))
|
||||
Ok(channel_name.to_string())
|
||||
}
|
||||
|
||||
fn memory_to_json(memory: MemoryRecord) -> serde_json::Value {
|
||||
@ -229,7 +225,6 @@ mod tests {
|
||||
let tool = MemoryManageTool::new(store);
|
||||
let context = ToolContext {
|
||||
channel_name: Some(TEST_CHANNEL.to_string()),
|
||||
sender_id: Some("user-1".to_string()),
|
||||
chat_id: Some("chat-1".to_string()),
|
||||
session_id: Some(format!("{}:chat-1", TEST_CHANNEL)),
|
||||
message_id: Some("msg-1".to_string()),
|
||||
@ -279,7 +274,6 @@ mod tests {
|
||||
let tool = MemoryManageTool::new(store);
|
||||
let context = ToolContext {
|
||||
channel_name: Some(TEST_CHANNEL.to_string()),
|
||||
sender_id: Some("user-1".to_string()),
|
||||
..ToolContext::default()
|
||||
};
|
||||
|
||||
|
||||
@ -189,11 +189,7 @@ fn scope_key_from_context(context: &ToolContext) -> Result<String, ToolResult> {
|
||||
.channel_name
|
||||
.as_deref()
|
||||
.ok_or_else(|| error_result("memory_search requires channel_name in tool context"))?;
|
||||
let sender_id = context
|
||||
.sender_id
|
||||
.as_deref()
|
||||
.ok_or_else(|| error_result("memory_search requires sender_id in tool context"))?;
|
||||
Ok(format!("{}:{}", channel_name, sender_id))
|
||||
Ok(channel_name.to_string())
|
||||
}
|
||||
|
||||
fn memory_to_json(memory: MemoryRecord) -> serde_json::Value {
|
||||
@ -236,7 +232,7 @@ mod tests {
|
||||
store
|
||||
.put_memory(&crate::storage::MemoryUpsert {
|
||||
scope_kind: "user".to_string(),
|
||||
scope_key: format!("{}:user-1", TEST_CHANNEL),
|
||||
scope_key: TEST_CHANNEL.to_string(),
|
||||
namespace: "preferences".to_string(),
|
||||
memory_key: "language".to_string(),
|
||||
content: "User prefers Chinese responses".to_string(),
|
||||
@ -252,7 +248,6 @@ mod tests {
|
||||
let tool = MemorySearchTool::new(store);
|
||||
let context = ToolContext {
|
||||
channel_name: Some(TEST_CHANNEL.to_string()),
|
||||
sender_id: Some("user-1".to_string()),
|
||||
chat_id: Some("chat-1".to_string()),
|
||||
session_id: Some(format!("{}:chat-1", TEST_CHANNEL)),
|
||||
message_id: Some("msg-2".to_string()),
|
||||
@ -310,7 +305,6 @@ mod tests {
|
||||
let tool = MemorySearchTool::new(store);
|
||||
let context = ToolContext {
|
||||
channel_name: Some(TEST_CHANNEL.to_string()),
|
||||
sender_id: Some("user-1".to_string()),
|
||||
..ToolContext::default()
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user