Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions workflow/agentworkflow/groupchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,35 @@ func (host *groupChatHostExecutor) handleTurn(ctx *workflow.Context, token workf
}
}

nextAgent, err := manager.SelectNextAgent(ctx, host.history)
dispatched, err := host.dispatchNextAgent(ctx, token, manager)
if err != nil {
return err
}
if dispatched {
return nil
}
return host.complete(ctx)
}

func (host *groupChatHostExecutor) dispatchNextAgent(ctx *workflow.Context, token workflow.TurnToken, manager *GroupChatManager) (bool, error) {
nextAgent, err := manager.SelectNextAgent(ctx, host.history)
if err != nil {
return false, err
}
if nextAgent == nil {
return host.complete(ctx)
return false, nil
}
nextBinding, ok := host.bindingForAgent(nextAgent)
if !ok {
// Selecting an agent that is not a participant ends the chat and
// yields the accumulated conversation, matching .NET GroupChatHost
// falling through to CompleteAsync on a lookup miss.
return host.complete(ctx)
return false, nil
}

host.iterationCount++
host.currentSpeakerExecutorID = nextBinding.ID
return ctx.SendMessage(nextBinding.ID, token)
return true, ctx.SendMessage(nextBinding.ID, token)
}

func (host *groupChatHostExecutor) shouldTerminate(ctx context.Context, manager *GroupChatManager) (bool, error) {
Expand Down
Loading