fix(agent): respect --session flag value when routing messages (#1039)
When starting the interactive agent with --session <name>, the provided session key was being ignored during routing. The router always fell back to 'agent:main:main' because plain names (without a colon) were not recognized as valid session keys. Root cause: the session key passed via --session flag (e.g. 'foobar') had no namespace prefix, so the routing logic treated it as unresolvable and defaulted to the hardcoded 'agent:main:main' session, causing all conversation history to accumulate in agent_main_main.json regardless of the --session value. Fix: before routing, check if the session key contains a colon; if not, prefix it with 'agent:main:' so that '--session foobar' correctly resolves to 'agent:main:foobar' and the session file is created as expected.
This commit is contained in:
parent
b82bb9acc0
commit
d46cde8345
1 changed files with 5 additions and 1 deletions
|
|
@ -10,7 +10,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/chzyer/readline"
|
||||
|
||||
"github.com/sipeed/picoclaw/cmd/picoclaw/internal"
|
||||
"github.com/sipeed/picoclaw/pkg/agent"
|
||||
"github.com/sipeed/picoclaw/pkg/bus"
|
||||
|
|
@ -23,6 +22,11 @@ func agentCmd(message, sessionKey, model string, debug bool) error {
|
|||
sessionKey = "cli:default"
|
||||
}
|
||||
|
||||
// If the user provides a plain name (no colon), treat it as a session label
|
||||
if !strings.Contains(sessionKey, ":") {
|
||||
sessionKey = fmt.Sprintf("agent:main:%s", sessionKey)
|
||||
}
|
||||
|
||||
if debug {
|
||||
logger.SetLevel(logger.DEBUG)
|
||||
fmt.Println("🔍 Debug mode enabled")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue