fix(session): restore thread and legacy compatibility

This commit is contained in:
Hoshina
2026-04-08 00:32:53 +08:00
parent a827d01d7c
commit 296077eabf
18 changed files with 568 additions and 46 deletions
+4
View File
@@ -805,6 +805,8 @@ func outboundTurnMetadata(
func outboundMessageForTurn(ts *turnState, content string) bus.OutboundMessage {
agentID, sessionKey, scope := outboundTurnMetadata(ts.agent.ID, ts.sessionKey, ts.opts.Dispatch.SessionScope)
return bus.OutboundMessage{
Channel: ts.channel,
ChatID: ts.chatID,
Context: outboundContextFromInbound(
ts.opts.Dispatch.InboundContext,
ts.channel,
@@ -2827,6 +2829,8 @@ turnLoop:
parts = append(parts, part)
}
outboundMedia := bus.OutboundMediaMessage{
Channel: ts.channel,
ChatID: ts.chatID,
Context: outboundContextFromInbound(
ts.opts.Dispatch.InboundContext,
ts.channel,
+4 -2
View File
@@ -3,6 +3,7 @@ package agent
import (
"context"
"fmt"
"sort"
"strings"
"sync"
@@ -319,7 +320,9 @@ func (al *AgentLoop) agentForSession(sessionKey string) *AgentInstance {
return nil
}
for _, agentID := range registry.ListAgentIDs() {
agentIDs := registry.ListAgentIDs()
sort.Strings(agentIDs)
for _, agentID := range agentIDs {
agent, ok := registry.GetAgent(agentID)
if !ok || agent == nil {
continue
@@ -331,7 +334,6 @@ func (al *AgentLoop) agentForSession(sessionKey string) *AgentInstance {
if scopedAgent, ok := registry.GetAgent(resolvedAgentID); ok {
return scopedAgent
}
return agent
}
return registry.GetDefaultAgent()