diff --git a/agent/task_executor.py b/agent/task_executor.py index efd5bb9..e0b3b1b 100644 --- a/agent/task_executor.py +++ b/agent/task_executor.py @@ -342,6 +342,8 @@ Return ONLY the JSON array, no other text.""" content = "" try: description = subtask["description"] + logger.info("════════ [任务开始] task=%s role=%s\n 描述: %s", + task_id, context.get("specialist_role", "general"), description) workspace_files = self._summarize_workspace() workspace_context = self._collect_workspace_context() user_prompt = context.get("user_prompt") or context.get("run_goal") or context.get("root_task_description") or "" @@ -437,6 +439,10 @@ Return your response as JSON with this structure: Return ONLY the JSON, no other text.""" content = await self._complete(prompt, max_tokens=4000) result = self._parse_json_response(content) + logger.info("──────── [任务产出] task=%s status=%s 文件=%s\n 说明: %s", + task_id, result.get("status"), + [f.get("path") for f in (result.get("files") or [])], + (result.get("changes") or result.get("summary") or "")[:600]) if result.get("status") == "completed": apply_result = await self._apply_file_changes(result.get("files", [])) result["files_modified"] = apply_result["files_modified"] @@ -539,7 +545,7 @@ Return ONLY the JSON, no other text.""" tools = await self._load_jina_tools() messages = [{"role": "user", "content": prompt}] - for _ in range(8): # max 8 tool-call rounds + for round_i in range(8): # max 8 tool-call rounds kwargs: dict = dict( model=self.model, messages=messages, @@ -553,6 +559,10 @@ Return ONLY the JSON, no other text.""" self._record_openai_usage(response) msg = response.choices[0].message + # 记录这一轮 LLM 的"思考/回复"(可观测 agent 怎么想的) + if msg.content: + logger.info("[LLM·第%d轮] 思考/回复:\n%s", round_i + 1, msg.content.strip()[:1200]) + if not msg.tool_calls: return msg.content or "" @@ -560,8 +570,13 @@ Return ONLY the JSON, no other text.""" messages.append(msg.model_dump(exclude_unset=True)) for tc in msg.tool_calls: args = json.loads(tc.function.arguments or "{}") + # 记录调用了哪个 tool、query 是什么 + logger.info("[TOOL·调用] %s 参数=%s", tc.function.name, + json.dumps(args, ensure_ascii=False)[:400]) result = await self._call_jina_tool(tc.function.name, args) - logger.info("Jina tool %s → %d chars", tc.function.name, len(result)) + # 记录 tool 返回了什么(搜索结果内容,截断) + logger.info("[TOOL·返回] %s (%d字):\n%s", tc.function.name, len(result), + (result or "").strip()[:1000]) messages.append({ "role": "tool", "tool_call_id": tc.id,