{"record":{"id":"c3ec93167eb7a286","repo":"BigPizzaV3/CodexPlusPlus","slug":"app-server-turn","errorCode":null,"errorMessage":"app-server turn 超时","messagePattern":"app-server turn 超时","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"tools/codex-wechat/codex_wechat.py","lineNumber":536,"sourceCode":"                if item.get(\"type\") == \"agentMessage\" and item.get(\"phase\") == \"final_answer\":\n                    final_item_id = str(item.get(\"id\") or \"\")\n            elif method == \"item/agentMessage/delta\":\n                if final_item_id and params.get(\"turnId\") == turn_id and params.get(\"itemId\") == final_item_id:\n                    final_chunks.append(str(params.get(\"delta\") or \"\"))\n            elif method == \"item/completed\":\n                item = params.get(\"item\") or {}\n                if item.get(\"type\") == \"agentMessage\" and item.get(\"phase\") == \"final_answer\":\n                    text = str(item.get(\"text\") or \"\")\n                    if text:\n                        final_chunks = [text]\n            elif method == \"turn/completed\" and params.get(\"turn\", {}).get(\"id\") == turn_id:\n                turn = params.get(\"turn\") or {}\n                if turn.get(\"status\") == \"failed\":\n                    error = str((turn.get(\"error\") or {}).get(\"message\") or \"turn failed\")\n                completed = True\n\n        if not completed:\n            raise TimeoutError(\"app-server turn 超时\")\n        if error:\n            raise RuntimeError(error)\n\n        reply = \"\".join(final_chunks).strip()\n        return reply or \"Codex 没有返回最终答复。\"\n\n\nclass CodexRunner:\n    def __init__(self, cfg: BridgeConfig):\n        self.cfg = cfg\n        self.app_server: AppServerCodexClient | None = None\n        if cfg.codex.backend == \"app-server\":\n            self.app_server = AppServerCodexClient(cfg)\n            atexit.register(self.app_server.close)\n\n    def run(self, user_id: str, prompt: str) -> str:\n        if self.app_server:\n            try:","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/codex-wechat/codex_wechat.py#L518-L554","documentation":"_collect_turn waits for turn/completed (or item/completed with a final answer) but the deadline elapses first, meaning the app-server never finished the submitted turn within the configured timeout — the model was still streaming, hung, or died without notification.","triggerScenarios":"Thrown at tools/codex-wechat/codex_wechat.py:536 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise the turn timeout in the bridge config for long prompts.","Check app-server logs/stderr captured by the reader thread for stalls or crashes.","Retry the turn once; if it repeats, restart the app-server process."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}