mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-06-18 03:30:53 +00:00
fix: route delegate session keys to correct agent loop (#127)
Delegate session keys (delegate:{uuid8}:{agentKey}:{delegationId}) were
not parsed by makeSchedulerRunFunc, causing fallback to default agent ID
which doesn't exist in managed-mode DBs. Add switch/case to handle both
agent: and delegate: prefixes.
This commit is contained in:
@@ -14,10 +14,20 @@ import (
|
||||
// It extracts the agentID from the session key and routes to the correct agent loop.
|
||||
func makeSchedulerRunFunc(agents *agent.Router, cfg *config.Config) scheduler.RunFunc {
|
||||
return func(ctx context.Context, req agent.RunRequest) (*agent.RunResult, error) {
|
||||
// Extract agentID from session key (format: agent:{agentId}:{rest})
|
||||
// Extract agentID from session key.
|
||||
// Supported formats:
|
||||
// agent:{agentId}:{rest}
|
||||
// delegate:{sourceUUID8}:{targetAgentKey}:{delegationId}
|
||||
agentID := cfg.ResolveDefaultAgentID()
|
||||
if parts := strings.SplitN(req.SessionKey, ":", 3); len(parts) >= 2 && parts[0] == "agent" {
|
||||
agentID = parts[1]
|
||||
if parts := strings.SplitN(req.SessionKey, ":", 4); len(parts) >= 2 {
|
||||
switch parts[0] {
|
||||
case "agent":
|
||||
agentID = parts[1]
|
||||
case "delegate":
|
||||
if len(parts) >= 3 {
|
||||
agentID = parts[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loop, err := agents.Get(agentID)
|
||||
|
||||
Reference in New Issue
Block a user