From 0f4533694ee21cffe9d838b7bcbbd660479613cc Mon Sep 17 00:00:00 2001 From: Rohit Kattimani <82595800+RohitKattimani@users.noreply.github.com> Date: Fri, 24 Apr 2026 08:04:08 +0530 Subject: [PATCH] Fix agent_id default value and connection closing Ensure agent_id defaults to 0 and close connection safely. --- backend/scripts/run_twitter_simulation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/scripts/run_twitter_simulation.py b/backend/scripts/run_twitter_simulation.py index caab9e9d..e39aa837 100644 --- a/backend/scripts/run_twitter_simulation.py +++ b/backend/scripts/run_twitter_simulation.py @@ -258,7 +258,7 @@ class IPCHandler: agent_prompts = {} # 记录每个agent的prompt for interview in interviews: - agent_id = interview.get("agent_id") + agent_id = interview.get("agent_id", 0) prompt = interview.get("prompt", "") try: @@ -333,7 +333,9 @@ class IPCHandler: except json.JSONDecodeError: result["response"] = info_json - conn.close() + finally: + if conn: + conn.close() except Exception as e: print(f" 读取Interview结果失败: {e}")