From 29bff9ca270d6a37d7a650a7e82345b1fc80f260 Mon Sep 17 00:00:00 2001 From: 666ghj <670939375@qq.com> Date: Fri, 5 Dec 2025 18:30:40 +0800 Subject: [PATCH] Refactor content handling in activity logging and simulation scripts - Removed content truncation logic from the AgentActivity class, allowing full content to be logged for posts, comments, and quotes. - Updated the `fetch_new_actions_from_db` function to retain complete content in action arguments, enhancing data accuracy. - Adjusted simulation scripts to ensure that full content is sent during action creation, improving the representation of agent activities. --- backend/app/services/zep_graph_memory_updater.py | 7 +------ backend/scripts/run_parallel_simulation.py | 10 ++++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/backend/app/services/zep_graph_memory_updater.py b/backend/app/services/zep_graph_memory_updater.py index b73b8f1..fff5057 100644 --- a/backend/app/services/zep_graph_memory_updater.py +++ b/backend/app/services/zep_graph_memory_updater.py @@ -63,9 +63,6 @@ class AgentActivity: def _describe_create_post(self) -> str: content = self.action_args.get("content", "") if content: - # 截取内容,避免过长 - if len(content) > 300: - content = content[:300] + "..." return f"发布了一条帖子:「{content}」" return "发布了一条帖子" @@ -86,7 +83,7 @@ class AgentActivity: content = self.action_args.get("content", "") if quoted_id: if content: - return f"引用帖子#{quoted_id}并评论:「{content[:100]}{'...' if len(content) > 100 else ''}」" + return f"引用帖子#{quoted_id}并评论:「{content}」" return f"引用了帖子#{quoted_id}" return "引用了一条帖子" @@ -98,8 +95,6 @@ class AgentActivity: content = self.action_args.get("content", "") post_id = self.action_args.get("post_id", "") if content: - if len(content) > 200: - content = content[:200] + "..." base = f"评论道:「{content}」" if post_id: base = f"在帖子#{post_id}下{base}" diff --git a/backend/scripts/run_parallel_simulation.py b/backend/scripts/run_parallel_simulation.py index 9277aba..1702656 100644 --- a/backend/scripts/run_parallel_simulation.py +++ b/backend/scripts/run_parallel_simulation.py @@ -251,12 +251,10 @@ def fetch_new_actions_from_db( except json.JSONDecodeError: action_args = {} - # 精简 action_args,只保留关键字段 + # 精简 action_args,只保留关键字段(保留完整内容,不截断) simplified_args = {} if 'content' in action_args: - content = action_args['content'] - # 截断过长的内容 - simplified_args['content'] = content[:200] + '...' if len(content) > 200 else content + simplified_args['content'] = action_args['content'] if 'post_id' in action_args: simplified_args['post_id'] = action_args['post_id'] if 'comment_id' in action_args: @@ -492,7 +490,7 @@ async def run_twitter_simulation( agent_id=agent_id, agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"), action_type="CREATE_POST", - action_args={"content": content[:100] + "..." if len(content) > 100 else content} + action_args={"content": content} ) total_actions += 1 initial_action_count += 1 @@ -677,7 +675,7 @@ async def run_reddit_simulation( agent_id=agent_id, agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"), action_type="CREATE_POST", - action_args={"content": content[:100] + "..." if len(content) > 100 else content} + action_args={"content": content} ) total_actions += 1 initial_action_count += 1