mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-16 08:15:05 +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:
1 parent
8ad580521d
commit
cc00a6f193
1 file changed
+13
-3
@@ -14,10 +14,20 @@ import (
|
|||||||
// It extracts the agentID from the session key and routes to the correct agent loop.
|
// 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 {
|
func makeSchedulerRunFunc(agents *agent.Router, cfg *config.Config) scheduler.RunFunc {
|
||||||
return func(ctx context.Context, req agent.RunRequest) (*agent.RunResult, error) {
|
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()
|
agentID := cfg.ResolveDefaultAgentID()
|
||||||
if parts := strings.SplitN(req.SessionKey, ":", 3); len(parts) >= 2 && parts[0] == "agent" {
|
if parts := strings.SplitN(req.SessionKey, ":", 4); len(parts) >= 2 {
|
||||||
agentID = parts[1]
|
switch parts[0] {
|
||||||
|
case "agent":
|
||||||
|
agentID = parts[1]
|
||||||
|
case "delegate":
|
||||||
|
if len(parts) >= 3 {
|
||||||
|
agentID = parts[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loop, err := agents.Get(agentID)
|
loop, err := agents.Get(agentID)
|
||||||
|
|||||||
Reference in new issue
Block a user