From dc46ff746b8a855f752602a2bbbceacce946da29 Mon Sep 17 00:00:00 2001 From: GuDaStudio Date: Fri, 14 Nov 2025 16:19:31 +0800 Subject: [PATCH] =?UTF-8?q?v0.7=EF=BC=9A=E5=A2=9E=E5=8A=A0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BFCC=E8=B0=83=E8=AF=95=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * v0.7:更新错误提示 * v0.7.1:修复None bug * v0.7.2:修复错误提取信息bug --- src/codexmcp/server.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/codexmcp/server.py b/src/codexmcp/server.py index cb6fb7a..7824f51 100644 --- a/src/codexmcp/server.py +++ b/src/codexmcp/server.py @@ -210,11 +210,18 @@ async def codex( line_dict = json.loads(line.strip()) all_messages.append(line_dict) item = line_dict.get("item", {}) - item_type = item.get("type") + item_type = item.get("type", "") if item_type == "agent_message": agent_messages = agent_messages + item.get("text", "") if line_dict.get("thread_id") is not None: thread_id = line_dict.get("thread_id") + if "fail" in line_dict.get("type", ""): + success = False + err_message = "codex error: " + line_dict.get("error", {}).get("message", "") + break + if "error" in line_dict.get("type", ""): + success = False + err_message = "codex error: " + line_dict.get("message", "") except json.JSONDecodeError as error: # Improved error handling: include problematic line err_message = line @@ -225,13 +232,13 @@ async def codex( success = False break - if thread_id is None: + if success and thread_id is None: success = False err_message = "Failed to get `SESSION_ID` from the codex session. \n\n" + err_message if success and len(agent_messages) == 0: success = False - err_message = "Failed to get `agent_messages` from the codex session. \n\nYou can try to set `return_all_messages` to `True` to get the full reasoning information. \n\n" + err_message = "Failed to get `agent_messages` from the codex session. \n\n You can try to set `return_all_messages` to `True` to get the full reasoning information. \n\n " + err_message if success: result: Dict[str, Any] = {