MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / __call__

Method __call__

src/agent/tool_calling_agent.py:269–388  ·  view source on GitHub ↗

Main entry point for tool calling agent through acp. Args: task (str): The task to complete. files (Optional[List[str]]): The files to attach to the task. Returns: AgentResponse: The response of the agent.

(self, 
                  task: str, 
                  files: Optional[List[str]] = None,
                  **kwargs
                  )

Source from the content-addressed store, hash-verified

267 return response_dict
268
269 async def __call__(self,
270 task: str,
271 files: Optional[List[str]] = None,
272 **kwargs
273 ) -> AgentResponse:
274 """
275 Main entry point for tool calling agent through acp.
276
277 Args:
278 task (str): The task to complete.
279 files (Optional[List[str]]): The files to attach to the task.
280
281 Returns:
282 AgentResponse: The response of the agent.
283 """
284 logger.info(f"| 🚀 Starting ToolCallingAgent: {task}")
285
286 ctx = kwargs.get("ctx", None)
287 if ctx is None:
288 ctx = SessionContext()
289
290 # Create tracer and record as local variables (coroutine-safe)
291 tracer, record = await self._get_tracer_and_record()
292
293 if files:
294 logger.info(f"| 📂 Attached files: {files}")
295 files = await asyncio.gather(*[self._extract_file_content(file) for file in files])
296 enhanced_task = await self._generate_enhanced_task(task, files)
297 else:
298 enhanced_task = task
299
300 # Get memory system name
301 memory_name = self.memory_name
302
303 task_id = "task_" + datetime.now().strftime("%Y%m%d-%H%M%S")
304
305 logger.info(f"| 📝 Context ID: {ctx.id}, Task ID: {task_id}")
306
307 # Memory session management (only if use_memory is enabled)
308 if self.use_memory and memory_name:
309 await memory_manager.start_session(memory_name=memory_name, ctx=ctx)
310
311 # Add task start event
312 await memory_manager.add_event(
313 memory_name=memory_name,
314 step_number=0,
315 event_type=EventType.TASK_START,
316 data=dict(task=enhanced_task),
317 agent_name=self.name,
318 task_id=task_id,
319 ctx=ctx
320 )
321 else:
322 logger.info(f"| ⏭️ Memory disabled (use_memory={self.use_memory}), skipping session management")
323
324 # Initialize messages
325 messages = await self._get_messages(enhanced_task, ctx=ctx)
326

Callers

nothing calls this directly

Calls 15

_think_and_toolMethod · 0.95
SessionContextClass · 0.90
AgentResponseClass · 0.90
AgentExtraClass · 0.90
warningMethod · 0.80
infoMethod · 0.45
getMethod · 0.45
_extract_file_contentMethod · 0.45
start_sessionMethod · 0.45
add_eventMethod · 0.45

Tested by

no test coverage detected