Skip to content

Commit 2334456

Browse files
committed
small fixups
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 3d0af00 commit 2334456

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

core/agent/agent.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ func (a *Agent) SharedState() *types.AgentSharedState {
180180
return a.sharedState
181181
}
182182

183+
// StartConversationConsumer starts the goroutine that dispatches new conversation
184+
// messages to subscribers. This must be called when using AskDirect() without Run(),
185+
// otherwise the ConversationAction handler will deadlock on the newConversations channel.
186+
func (a *Agent) StartConversationConsumer() {
187+
a.startNewConversationsConsumer()
188+
}
189+
183190
func (a *Agent) startNewConversationsConsumer() {
184191
go func() {
185192
for {

core/state/pool.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,10 @@ func (a *AgentPool) createAgentWithoutRun(name, pooldir string, config *AgentCon
856856
a.agents[name] = agent
857857
a.managers[name] = manager
858858

859+
// Start the conversation consumer so ConversationAction doesn't deadlock.
860+
// This is normally started by Run(), but we skip Run() in distributed mode.
861+
agent.StartConversationConsumer()
862+
859863
xlog.Info("Agent created (no Run)", "name", name)
860864
return nil
861865
}

0 commit comments

Comments
 (0)