A programming framework for agentic AI
Set logging of internal messages to debug (#3694)
Eric Zhuffb16d560a33
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_logging.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_logging.pyindex 1c6575e02..d0c3b65b5 100644--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_logging.py+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_logging.py@@ -62,7 +62,7 @@ class ConsoleLogHandler(BaseLogHandler):def emit(self, record: logging.LogRecord) -> None:ts = datetime.fromtimestamp(record.created).isoformat()- if isinstance(record.msg, ContentPublishEvent | ToolCallEvent | ToolCallResultEvent):+ if isinstance(record.msg, ContentPublishEvent):sys.stdout.write(self._format_chat_message(source_agent_id=record.msg.source,@@ -71,6 +71,20 @@ class ConsoleLogHandler(BaseLogHandler):))sys.stdout.flush()+ elif isinstance(record.msg, ToolCallEvent):+ sys.stdout.write(+ f"\n{'-'*75} \n"+ f"\033[91m[{ts}], Tool Call:\033[0m\n"+ f"\n{self.serialize_content(record.msg.agent_message)}"+ )+ sys.stdout.flush()+ elif isinstance(record.msg, ToolCallResultEvent):+ sys.stdout.write(+ f"\n{'-'*75} \n"+ f"\033[91m[{ts}], Tool Call Result:\033[0m\n"+ f"\n{self.serialize_content(record.msg.agent_message)}"+ )+ sys.stdout.flush()elif isinstance(record.msg, SelectSpeakerEvent):sys.stdout.write(f"\n{'-'*75} \n"diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_base_chat_agent_container.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_base_chat_agent_container.pyindex 23f6fdc62..1f5dc3065 100644--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_base_chat_agent_container.py+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_base_chat_agent_container.py@@ -53,7 +53,7 @@ class BaseChatAgentContainer(SequentialRoutedAgent):# Handle tool calls.while isinstance(response, ToolCallMessage):# Log the tool call.- event_logger.info(ToolCallEvent(agent_message=response, source=self.id))+ event_logger.debug(ToolCallEvent(agent_message=response, source=self.id))results: List[FunctionExecutionResult | BaseException] = await asyncio.gather(*[@@ -79,7 +79,7 @@ class BaseChatAgentContainer(SequentialRoutedAgent):# Create a new tool call result message.feedback = ToolCallResultMessage(content=function_results, source=self._tool_agent_id.type)# Log the feedback.- event_logger.info(ToolCallResultEvent(agent_message=feedback, source=self._tool_agent_id))+ event_logger.debug(ToolCallResultEvent(agent_message=feedback, source=self._tool_agent_id))response = await self._agent.on_messages([feedback], ctx.cancellation_token)# Publish the response.diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_selector_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_selector_group_chat.pyindex 0d6df0212..66724b445 100644--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_selector_group_chat.py+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/group_chat/_selector_group_chat.py@@ -104,7 +104,7 @@ class SelectorGroupChatManager(BaseGroupChatManager):else:agent_name = participants[0]self._previous_speaker = agent_name- event_logger.info(SelectSpeakerEvent(selected_speaker=agent_name, source=self.id))+ event_logger.debug(SelectSpeakerEvent(selected_speaker=agent_name, source=self.id))return agent_namedef _mentioned_agents(self, message_content: str, agent_names: List[str]) -> Dict[str, int]:diff --git a/python/packages/autogen-core/tests/test_worker_runtime.py b/python/packages/autogen-core/tests/test_worker_runtime.pyindex 0e232243d..d58233c3a 100644--- a/python/packages/autogen-core/tests/test_worker_runtime.py+++ b/python/packages/autogen-core/tests/test_worker_runtime.py@@ -52,7 +52,7 @@ async def test_agent_types_must_be_unique_single_worker() -> None:@pytest.mark.asyncioasync def test_agent_types_must_be_unique_multiple_workers() -> None:- host_address = "localhost:50059"+ host_address = "localhost:50052"host = WorkerAgentRuntimeHost(address=host_address)host.start()@@ -77,7 +77,7 @@ async def test_agent_types_must_be_unique_multiple_workers() -> None:@pytest.mark.asyncioasync def test_register_receives_publish() -> None:- host_address = "localhost:50060"+ host_address = "localhost:50053"host = WorkerAgentRuntimeHost(address=host_address)host.start()@@ -122,7 +122,7 @@ async def test_register_receives_publish() -> None:@pytest.mark.asyncioasync def test_register_receives_publish_cascade_single_worker() -> None:- host_address = "localhost:50053"+ host_address = "localhost:50054"host = WorkerAgentRuntimeHost(address=host_address)host.start()runtime = WorkerAgentRuntime(host_address=host_address)@@ -159,7 +159,7 @@ async def test_register_receives_publish_cascade_single_worker() -> None:@pytest.mark.asyncioasync def test_register_receives_publish_cascade_multiple_workers() -> None:logging.basicConfig(level=logging.DEBUG)- host_address = "localhost:50057"+ host_address = "localhost:50055"host = WorkerAgentRuntimeHost(address=host_address)host.start()@@ -202,7 +202,7 @@ async def test_register_receives_publish_cascade_multiple_workers() -> None:@pytest.mark.asyncioasync def test_default_subscription() -> None:- host_address = "localhost:50054"+ host_address = "localhost:50056"host = WorkerAgentRuntimeHost(address=host_address)host.start()worker = WorkerAgentRuntime(host_address=host_address)@@ -236,7 +236,7 @@ async def test_default_subscription() -> None:@pytest.mark.asyncioasync def test_default_subscription_other_source() -> None:- host_address = "localhost:50056"+ host_address = "localhost:50057"host = WorkerAgentRuntimeHost(address=host_address)host.start()runtime = WorkerAgentRuntime(host_address=host_address)@@ -270,7 +270,7 @@ async def test_default_subscription_other_source() -> None:@pytest.mark.asyncioasync def test_type_subscription() -> None:- host_address = "localhost:50055"+ host_address = "localhost:50058"host = WorkerAgentRuntimeHost(address=host_address)host.start()worker = WorkerAgentRuntime(host_address=host_address)@@ -338,7 +338,7 @@ async def test_duplicate_subscription() -> None:@pytest.mark.asyncioasync def test_disconnected_agent() -> None:- host_address = "localhost:50059"+ host_address = "localhost:50060"host = WorkerAgentRuntimeHost(address=host_address)host.start()worker1 = WorkerAgentRuntime(host_address=host_address)@@ -412,7 +412,7 @@ async def test_grpc_max_message_size() -> None:("grpc.max_send_message_length", new_max_size),("grpc.max_receive_message_length", new_max_size),]- host_address = "localhost:50059"+ host_address = "localhost:50061"host = WorkerAgentRuntimeHost(address=host_address, extra_grpc_config=extra_grpc_config)worker1 = WorkerAgentRuntime(host_address=host_address, extra_grpc_config=extra_grpc_config)worker2 = WorkerAgentRuntime(host_address=host_address)