@@ -34,7 +34,7 @@ def __init__(
3434 self .current_chat_turns = 0 # 当前对话轮次计数器
3535 self .user_output = user_output
3636
37- async def run (self , prompt : str , system_prompt : str ) -> str :
37+ async def run (self , prompt : str , system_prompt : str , sub_title : str ) -> str :
3838 """
3939 执行agent的对话并返回结果和总结
4040
@@ -54,7 +54,9 @@ async def run(self, prompt: str, system_prompt: str) -> str:
5454
5555 # 获取历史消息用于本次对话
5656 response = await self .model .chat (
57- history = self .chat_history , agent_name = self .__class__ .__name__
57+ history = self .chat_history ,
58+ agent_name = self .__class__ .__name__ ,
59+ sub_title = sub_title ,
5860 )
5961 response_content = response .choices [0 ].message .content
6062 self .chat_history .append ({"role" : "assistant" , "content" : response_content })
@@ -140,7 +142,7 @@ async def run(self, prompt: str, subtask_title: str) -> CoderToWriter:
140142 f"Failed to complete task after { self .max_retries } attempts. Last error: { last_error_message } "
141143 )
142144
143- # try:
145+ # try:
144146 while (
145147 not task_completed
146148 and retry_count < self .max_retries
@@ -189,6 +191,7 @@ async def run(self, prompt: str, subtask_title: str) -> CoderToWriter:
189191 )
190192
191193 # 执行工具调用
194+ logger .warning ("执行工具调用" )
192195 (
193196 text_to_gpt ,
194197 error_occurred ,
@@ -207,6 +210,8 @@ async def run(self, prompt: str, subtask_title: str) -> CoderToWriter:
207210 )
208211
209212 if error_occurred :
213+ logger .warning ("代码执行错误" )
214+
210215 retry_count += 1
211216 last_error_message = error_message
212217 reflection_prompt = get_reflection_prompt (error_message , code )
@@ -224,6 +229,8 @@ async def run(self, prompt: str, subtask_title: str) -> CoderToWriter:
224229 # 检查任务完成情况时也计入对话轮次
225230 self .current_chat_turns += 1
226231 # 使用所有执行结果生成检查提示
232+ logger .warning ("判断是否完成" )
233+
227234 completion_check_prompt = get_completion_check_prompt (
228235 prompt , text_to_gpt
229236 )
@@ -245,6 +252,7 @@ async def run(self, prompt: str, subtask_title: str) -> CoderToWriter:
245252 hasattr (completion_response .choices [0 ].message , "tool_calls" )
246253 and completion_response .choices [0 ].message .tool_calls
247254 ):
255+ logger .warning ("没有调用工具,代表已经完成了" )
248256 task_completed = True
249257 return completion_response .choices [0 ].message .content
250258
@@ -282,28 +290,25 @@ async def run(
282290 self ,
283291 prompt : str ,
284292 available_images : list [str ] = None ,
285- static_prefix : str = "/static/" ,
293+ sub_title : str = None ,
286294 ) -> str :
287295 """
288296 执行写作任务
289297 Args:
290298 prompt: 写作提示
291299 available_images: 可用的图片相对路径列表(如 20250420-173744-9f87792c/编号_分布.png)
292- static_prefix: 静态资源前缀
300+ sub_title: 子任务标题
293301 """
302+ logger .info (f"subtitle是:{ sub_title } " )
303+
294304 if available_images :
295305 self .available_images = available_images
296306 # 拼接成完整URL
297- image_list = "\n " .join (
298- [
299- f"- { static_prefix } { img if img .startswith ('/' ) else '/' + img } "
300- for img in available_images
301- ]
302- )
307+ image_list = "," .join (available_images )
303308 image_prompt = f"\n 可用的图片链接列表:\n { image_list } \n 请在写作时适当引用这些图片链接。"
304309 prompt = prompt + image_prompt
305310
306- return await super ().run (prompt , self .system_prompt )
311+ return await super ().run (prompt , self .system_prompt , sub_title )
307312
308313 async def summarize (self ) -> str :
309314 """
0 commit comments