microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
27.96k stars 4.08k forks source link

[Bug]: Setting "silent": True in group chats stops the agent's output from printing to the terminal, but the agent's output is still sent to a client via websockets #3033

Open tyler-suard-parker opened 3 days ago

tyler-suard-parker commented 3 days ago

Describe the bug

I am connecting to AutoGen via a websocket interface like in the tutorial here: https://github.com/microsoft/autogen/blob/main/notebook/agentchat_websockets.ipynb

When I run a group chat, I can set some of the agents to "silent": True, and the agents will not output any messages to the console.

However, these agents' outputs still get streamed back to the client from the websocket. I would like for "silent": True to block agent output from both printing in the terminal and sending via websocket.

Steps to reproduce

  1. Use the notebook here https://github.com/microsoft/autogen/blob/main/notebook/agentchat_websockets.ipynb
  2. Set up a group chat with 2 agents
  3. Set the agents to "silent":True
  4. Run the autogen server and make a request to it. The agents will not output any information to the terminal to the server, but they will still stream information back to the client.

Model Used

No response

Expected Behavior

setting "silent":True on an agent should stop its output both in the terminal and in the stream.

Screenshots and logs

No response

Additional Information

No response

tyler-suard-parker commented 3 days ago

await groupchat_boss_agent.a_initiate_chats( [ { "chat_id": 1, "recipient": 1_search_agent, "message": f"Please execute the following plan: \n{plan}", "silent": True, "summary_method": "reflection_with_llm", }, { "chat_id": 2, "recipient": 2_search_agent, "message": f"Please execute the following plan: \n{plan}", "silent": True, "summary_method": "reflection_with_llm", },

Hk669 commented 3 days ago

@krishnashed would you like to take up this issue? thanks

krishnashed commented 3 days ago

Ya sure! As this is inline with another issue I'm working on anyways

tyler-suard-parker commented 2 days ago

@krishnashed I think I've tracked it down to the chat.py file:

if chat_info.get("verbose", False): 
    iostream.print(colored("Message:\n" + print_message, "blue"), flush=True)
    iostream.print(colored("Carryover:\n" + print_carryover, "blue"), flush=True)
iostream.print(colored("\n" + "*" * 80, "blue"), flush=True, sep="")

Why would it send messages to the iostream websocket if verbose is False?

Also why would it send messages to the iostream if silent is True? https://github.com/microsoft/autogen/blob/23c1dec206227f4eb30b00e15eebf32c0750e47e/autogen/agentchat/chat.py#L249

krishnashed commented 1 day ago

@tyler-suard-parker ill check chat.py and get back, thanks for the heads up!