@@ -185,157 +185,3 @@ async def task_agent_curd(
185185 break
186186 already_iterations += 1
187187 return Result .resolve (None )
188-
189-
190- # @track_process
191- # async def task_agent_curd_debug(
192- # project_id: asUUID,
193- # session_id: asUUID,
194- # previous_messages: List[MessageBlob],
195- # messages: List[MessageBlob],
196- # max_iterations=3, # task curd agent only receive one turn of actions
197- # ) -> Result[None]:
198- # async with DB_CLIENT.get_session_context() as db_session:
199- # r = await TD.fetch_current_tasks(db_session, session_id)
200- # tasks, eil = r.unpack()
201- # if eil:
202- # return r
203-
204- # r = await TD.fetch_planning_task(db_session, session_id)
205- # planning_section, eil = r.unpack()
206- # if eil:
207- # return r
208-
209- # task_section = pack_task_section(tasks)
210- # previous_messages_section = pack_previous_messages_section(
211- # planning_section, tasks, previous_messages
212- # )
213- # current_messages_section = pack_current_message_with_ids(messages)
214-
215- # LOG.info(f"Task Section: {task_section}")
216- # LOG.info(f"Previous Messages Section: {previous_messages_section}")
217- # LOG.info(f"Current Messages Section: {current_messages_section}")
218-
219- # json_tools = [tool.model_dump() for tool in TaskPrompt.tool_schema()]
220- # already_iterations = 0
221- # _messages = [
222- # {
223- # "role": "user",
224- # "content": TaskPrompt.pack_task_input(
225- # previous_messages_section, current_messages_section, task_section
226- # ),
227- # }
228- # ]
229-
230- # FAKE_TOOLS = {
231- # 0: [
232- # {
233- # "id": "1",
234- # "type": "function",
235- # "function": {
236- # "name": "insert_task",
237- # "arguments": {
238- # "after_task_order": 0,
239- # "task_description": "Search and collect the latest information about iPhone 15 Pro Max",
240- # },
241- # },
242- # },
243- # {
244- # "id": "2",
245- # "type": "function",
246- # "function": {
247- # "name": "insert_task",
248- # "arguments": {
249- # "after_task_order": 1,
250- # "task_description": "Report the collected information about iPhone 15 Pro Max to the user",
251- # },
252- # },
253- # },
254- # ],
255- # 1: [
256- # {
257- # "id": "1",
258- # "type": "function",
259- # "function": {
260- # "name": "append_messages_to_task",
261- # "arguments": {"task_order": 1, "message_ids": [4, 5, 6, 7, 8]},
262- # },
263- # },
264- # {
265- # "id": "2",
266- # "type": "function",
267- # "function": {
268- # "name": "update_task",
269- # "arguments": {"task_order": 1, "task_status": "success"},
270- # },
271- # },
272- # {
273- # "id": "3",
274- # "type": "function",
275- # "function": {
276- # "name": "append_messages_to_task",
277- # "arguments": {"task_order": 2, "message_ids": [9]},
278- # },
279- # },
280- # {
281- # "id": "4",
282- # "type": "function",
283- # "function": {
284- # "name": "update_task",
285- # "arguments": {"task_order": 2, "task_status": "success"},
286- # },
287- # },
288- # ],
289- # }
290- # while already_iterations < max_iterations:
291- # from ...schema.llm import LLMToolCall
292-
293- # if already_iterations not in FAKE_TOOLS:
294- # print("No fake tools found, stop iterations")
295- # break
296- # use_tools = FAKE_TOOLS[already_iterations]
297- # use_tools = [LLMToolCall(**tool) for tool in use_tools]
298- # just_finish = False
299- # tool_response = []
300- # USE_CTX = None
301- # for tool_call in use_tools:
302- # try:
303- # tool_name = tool_call.function.name
304- # if tool_name == "finish":
305- # just_finish = True
306- # continue
307- # tool_arguments = tool_call.function.arguments
308- # tool = TASK_TOOLS[tool_name]
309- # with bound_logging_vars(tool=tool_name):
310- # async with DB_CLIENT.get_session_context() as db_session:
311- # USE_CTX = await build_task_ctx(
312- # db_session,
313- # project_id,
314- # session_id,
315- # messages,
316- # before_use_ctx=USE_CTX,
317- # )
318- # r = await tool.handler(USE_CTX, tool_arguments)
319- # t, eil = r.unpack()
320- # if eil:
321- # return r
322- # LOG.info(f"Tool Call: {tool_name} - {tool_arguments} -> {t}")
323- # tool_response.append(
324- # {
325- # "role": "tool",
326- # "tool_call_id": tool_call.id,
327- # "content": t,
328- # }
329- # )
330- # if tool_name in NEED_UPDATE_CTX:
331- # USE_CTX = None
332- # except KeyError as e:
333- # return Result.reject(f"Tool {tool_name} not found: {str(e)}")
334- # except Exception as e:
335- # return Result.reject(f"Tool {tool_name} error: {str(e)}")
336- # _messages.extend(tool_response)
337- # if just_finish:
338- # LOG.info("finish function is called")
339- # break
340- # already_iterations += 1
341- # return Result.resolve(None)
0 commit comments