Skip to content

Conversation

@jiancui-research
Copy link
Contributor

Why are these changes needed?

Update to support new API: initiate_group_chat. Previously, to use the policy-guided safeguard with initiate_chat it would be:

apply_safeguard_policy(groupchat_manager=manager, policy=policy, safeguard_llm_config=llm_config)
user_proxy.initiate_chat(manager, message=user_query)

To use with initiate_group_chat:

result, context, last_agent = initiate_group_chat(
    pattern=pattern,
    messages=user_query,
    max_rounds=10,
    safeguard_policy=policy,
    safeguard_llm_config=llm_config,
)

This PR updates the code & documentation to reflect the new recommended approach

Related issue number

Checks

… to add additional hooks and include logic to enable safeguard

policy format and tool message bug handling

add changes for type check workflow

fix "Argument "target" to "LLMGuardrail" has incompatible type "None"; expected "TransitionTarget"  "

fix type cheking issues & better formatting

fix type error in test file
update safeguards doc
@randombet
Copy link
Collaborator

randombet commented Oct 1, 2025

Look good in general.

@jiancui-research I have a few questions.
Does this change support run_group_chat method? Could you verify?
https://github.com/ag2ai/ag2/blob/main/autogen/agentchat/group/multi_agent_chat.py#L155

If yes, could you add an example in the notebook and update the documentation?
If not, you may address this in a separate PR.

Could you fix the pre-commit error as well?

@jiancui-research
Copy link
Contributor Author

@randombet, thanks for your comment.

I double checked. The current implementation also supports run_groupchat. I updated the demo notebook and document to include this API!

@randombet randombet enabled auto-merge October 14, 2025 18:07
Copy link
Collaborator

@randombet randombet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@randombet randombet added this pull request to the merge queue Oct 14, 2025
Merged via the queue into ag2ai:main with commit 80d13c7 Oct 14, 2025
13 checks passed
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 23.37662% with 59 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/agentchat/group/safeguards/enforcer.py 18.51% 40 Missing and 4 partials ⚠️
autogen/agentchat/group/safeguards/api.py 0.00% 6 Missing and 1 partial ⚠️
autogen/agentchat/group/multi_agent_chat.py 14.28% 6 Missing ⚠️
autogen/agentchat/group/group_tool_executor.py 77.77% 2 Missing ⚠️
Files with missing lines Coverage Δ
autogen/agentchat/group/group_tool_executor.py 87.61% <77.77%> (-0.93%) ⬇️
autogen/agentchat/group/multi_agent_chat.py 29.16% <14.28%> (-1.61%) ⬇️
autogen/agentchat/group/safeguards/api.py 55.17% <0.00%> (-3.37%) ⬇️
autogen/agentchat/group/safeguards/enforcer.py 23.37% <18.51%> (-1.07%) ⬇️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude claude bot mentioned this pull request Oct 22, 2025
3 tasks
@marklysze marklysze changed the title Update policy-guided safeguard to support initiate_group_chat API misc: Update policy-guided safeguard to support initiate_group_chat API Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants