mirror of
https://github.com/GuDaStudio/codexmcp.git
synced 2026-02-05 02:00:24 +08:00
v0.7:增加错误提示信息,方便CC调试 (#3)
* v0.7:更新错误提示 * v0.7.1:修复None bug * v0.7.2:修复错误提取信息bug
This commit is contained in:
@@ -210,11 +210,18 @@ async def codex(
|
|||||||
line_dict = json.loads(line.strip())
|
line_dict = json.loads(line.strip())
|
||||||
all_messages.append(line_dict)
|
all_messages.append(line_dict)
|
||||||
item = line_dict.get("item", {})
|
item = line_dict.get("item", {})
|
||||||
item_type = item.get("type")
|
item_type = item.get("type", "")
|
||||||
if item_type == "agent_message":
|
if item_type == "agent_message":
|
||||||
agent_messages = agent_messages + item.get("text", "")
|
agent_messages = agent_messages + item.get("text", "")
|
||||||
if line_dict.get("thread_id") is not None:
|
if line_dict.get("thread_id") is not None:
|
||||||
thread_id = line_dict.get("thread_id")
|
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:
|
except json.JSONDecodeError as error:
|
||||||
# Improved error handling: include problematic line
|
# Improved error handling: include problematic line
|
||||||
err_message = line
|
err_message = line
|
||||||
@@ -225,13 +232,13 @@ async def codex(
|
|||||||
success = False
|
success = False
|
||||||
break
|
break
|
||||||
|
|
||||||
if thread_id is None:
|
if success and thread_id is None:
|
||||||
success = False
|
success = False
|
||||||
err_message = "Failed to get `SESSION_ID` from the codex session. \n\n" + err_message
|
err_message = "Failed to get `SESSION_ID` from the codex session. \n\n" + err_message
|
||||||
|
|
||||||
if success and len(agent_messages) == 0:
|
if success and len(agent_messages) == 0:
|
||||||
success = False
|
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:
|
if success:
|
||||||
result: Dict[str, Any] = {
|
result: Dict[str, Any] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user