Execute an agent orchestration tool (agent_spawn, agent_stop, etc.). Agent tools are internal operations that bypass the MCP ToolManager and all guard checks. They delegate to the AgentManager stored on the ChatContext.
(
self,
tool_name: str,
arguments: dict,
llm_tool_name: str,
call_id: str,
)
| 810 | self._add_tool_result_to_history(llm_tool_name, call_id, result_text) |
| 811 | |
| 812 | async def _handle_agent_tool( |
| 813 | self, |
| 814 | tool_name: str, |
| 815 | arguments: dict, |
| 816 | llm_tool_name: str, |
| 817 | call_id: str, |
| 818 | ) -> None: |
| 819 | """Execute an agent orchestration tool (agent_spawn, agent_stop, etc.). |
| 820 | |
| 821 | Agent tools are internal operations that bypass the MCP ToolManager |
| 822 | and all guard checks. They delegate to the AgentManager stored on |
| 823 | the ChatContext. |
| 824 | """ |
| 825 | agent_manager = getattr(self.context, "agent_manager", None) |
| 826 | if agent_manager is None: |
| 827 | self._add_tool_result_to_history( |
| 828 | llm_tool_name, call_id, "Agent tools are not enabled." |
| 829 | ) |
| 830 | return |
| 831 | |
| 832 | logger.info("Agent tool %s called with args: %s", tool_name, arguments) |
| 833 | |
| 834 | from mcp_cli.agents.tools import handle_agent_tool |
| 835 | |
| 836 | caller_id = getattr(self.context, "agent_id", "default") |
| 837 | result_text = await handle_agent_tool( |
| 838 | tool_name, arguments, agent_manager, caller_agent_id=caller_id |
| 839 | ) |
| 840 | |
| 841 | self._add_tool_result_to_history(llm_tool_name, call_id, result_text) |
| 842 | |
| 843 | async def _handle_vm_tool( |
| 844 | self, |
no test coverage detected