Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

This PR addresses several critical issues with the GroupPersona implementation that were causing problems with group chat functionality while maintaining full backward compatibility with 1-on-1 conversations.

Issues Fixed

1. Nested JSON Serialization Problem

The original implementation stored BotPersonas as a List<BasePersona>, which created "nested dolls" when serialized to JSON:

{
  "BotPersonas": [
    {
      "Name": "Alice",
      "Bio": "...",
      "UniqueName": "alice_bot",
      // ... entire persona object nested here
    }
  ]
}

This made individual personas difficult to edit independently and violated the principle of keeping personas as separate entities.

Fix: Added [JsonIgnore] to BotPersonas and introduced BotPersonaNames as a List<string> for serialization:

{
  "BotPersonaNames": ["alice_bot", "bob_bot"],
  "CurrentBotId": "bob_bot"
  // No nested persona objects
}

2. Dynamic Persona Loading

The group now dynamically populates BotPersonas during BeginChat() using LLMSystem.LoadedPersonas, ensuring personas remain independent while being properly linked at runtime.

3. Brain Functionality Conflicts

Brain functionality was interfering with group conversations since it's designed for single personas. Added automatic Brain disabling for group chats:

private bool IsBrainDisabled => LLMSystem.IsGroupConversation;

public void OnUserPost(string userinput)
{
    if (IsBrainDisabled)
        return;
    // ... rest of brain logic
}

4. Enhanced World Info Handling

Improved UpdateRagAndInserts() to consider both group-level and active persona's individual MyWorlds:

// Add world entries from the group/bot itself
if (Bot.MyWorlds.Count > 0) { /* ... */ }

// If in group conversation, also add world entries from current active persona
if (IsGroupConversation)
{
    var currentBot = GetCurrentGroupBot();
    if (currentBot?.MyWorlds.Count > 0) { /* ... */ }
}

Testing

Added comprehensive tests covering:

  • Serialization/deserialization cycles
  • Dynamic persona loading from LoadedPersonas
  • Brain disable functionality
  • Group macro resolution
  • World info handling

All tests pass and confirm that:

  • ✅ No nested personas in JSON
  • ✅ Individual personas remain editable
  • ✅ Group functionality works correctly
  • ✅ 1-on-1 chat compatibility maintained
  • ✅ Brain conflicts resolved
  • ✅ Enhanced MyWorlds support

Breaking Changes

None. All changes are backward compatible with existing 1-on-1 chat functionality.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] GroupPersona was implemented recently to make it possible to handle group chats between one user and multiple AI driven characters. Current implementation is a bit naive. Here are a few problems. Fix those you can without breaking 1 on 1 chat function... Fix GroupPersona serialization and group chat functionality issues Sep 2, 2025
Copilot AI requested a review from SerialKicked September 2, 2025 22:55
@SerialKicked SerialKicked marked this pull request as ready for review September 2, 2025 23:02
@SerialKicked SerialKicked merged commit fdb4501 into master Sep 2, 2025
@SerialKicked SerialKicked deleted the copilot/fix-bd26f53d-190a-4df3-b3b9-d4667db61acd branch September 2, 2025 23:03
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