MCPcopy
hub / github.com/agent0ai/agent-zero / process

Method process

api/chat_remove.py:8–34  ·  view source on GitHub ↗
(self, input: Input, request: Request)

Source from the content-addressed store, hash-verified

6
7class RemoveChat(ApiHandler):
8 async def process(self, input: Input, request: Request) -> Output:
9 ctxid = input.get("context", "")
10
11 scheduler = TaskScheduler.get()
12 scheduler.cancel_tasks_by_context(ctxid, terminate_thread=True)
13
14 context = AgentContext.use(ctxid)
15 if context:
16 # stop processing any tasks
17 context.reset()
18
19 AgentContext.remove(ctxid)
20 persist_chat.remove_chat(ctxid)
21
22 await scheduler.reload()
23
24 tasks = scheduler.get_tasks_by_context_id(ctxid)
25 for task in tasks:
26 await scheduler.remove_task_by_uuid(task.uuid)
27
28 # Context removal affects global chat/task lists in all tabs.
29 from helpers.state_monitor_integration import mark_dirty_all
30 mark_dirty_all(reason="api.chat_remove.RemoveChat")
31
32 return {
33 "message": "Context removed.",
34 }

Callers 1

processMethod · 0.95

Calls 9

mark_dirty_allFunction · 0.90
useMethod · 0.80
getMethod · 0.45
resetMethod · 0.45
removeMethod · 0.45
reloadMethod · 0.45
remove_task_by_uuidMethod · 0.45

Tested by

no test coverage detected