fix(cli): satisfy reset command lint checks
This commit is contained in:
parent
af7bc26a58
commit
7d01b5d70a
5 changed files with 28 additions and 12 deletions
|
|
@ -335,7 +335,7 @@ func (al *AgentLoop) buildCommandsRuntime(
|
||||||
return al.contextManager.Clear(ctx, opts.SessionKey)
|
return al.contextManager.Clear(ctx, opts.SessionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
rt.ResetSession = func(clear bool) (string, error) {
|
rt.ResetSession = func(clearOverride bool) (string, error) {
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
return "", fmt.Errorf("process options not available")
|
return "", fmt.Errorf("process options not available")
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +343,7 @@ func (al *AgentLoop) buildCommandsRuntime(
|
||||||
if routeSessionKey == "" {
|
if routeSessionKey == "" {
|
||||||
return "", fmt.Errorf("route session key not available")
|
return "", fmt.Errorf("route session key not available")
|
||||||
}
|
}
|
||||||
if clear {
|
if clearOverride {
|
||||||
return "", al.clearSessionOverride(routeSessionKey)
|
return "", al.clearSessionOverride(routeSessionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
|
||||||
Dispatch: DispatchRequest{
|
Dispatch: DispatchRequest{
|
||||||
RouteSessionKey: allocation.SessionKey,
|
RouteSessionKey: allocation.SessionKey,
|
||||||
SessionKey: sessionKey,
|
SessionKey: sessionKey,
|
||||||
SessionAliases: buildSessionAliases(sessionKey, sessionAliasCandidates(allocation.SessionKey, sessionKey, allocation.SessionAliases, msg.SessionKey)...),
|
SessionAliases: buildSessionAliases(
|
||||||
|
sessionKey,
|
||||||
|
sessionAliasCandidates(
|
||||||
|
allocation.SessionKey,
|
||||||
|
sessionKey,
|
||||||
|
allocation.SessionAliases,
|
||||||
|
msg.SessionKey,
|
||||||
|
)...,
|
||||||
|
),
|
||||||
InboundContext: cloneInboundContext(&msg.Context),
|
InboundContext: cloneInboundContext(&msg.Context),
|
||||||
RouteResult: cloneResolvedRoute(&route),
|
RouteResult: cloneResolvedRoute(&route),
|
||||||
SessionScope: session.CloneScope(&allocation.Scope),
|
SessionScope: session.CloneScope(&allocation.Scope),
|
||||||
|
|
|
||||||
|
|
@ -792,26 +792,26 @@ func TestProcessMessage_ResetClearRestoresDefaultSession(t *testing.T) {
|
||||||
defaultAgent := al.GetRegistry().GetDefaultAgent()
|
defaultAgent := al.GetRegistry().GetDefaultAgent()
|
||||||
originalHistoryLen := len(defaultAgent.Sessions.GetHistory(routeSessionKey))
|
originalHistoryLen := len(defaultAgent.Sessions.GetHistory(routeSessionKey))
|
||||||
|
|
||||||
if _, err := al.processMessage(context.Background(), testInboundMessage(bus.InboundMessage{
|
if _, procErr := al.processMessage(context.Background(), testInboundMessage(bus.InboundMessage{
|
||||||
Channel: "telegram",
|
Channel: "telegram",
|
||||||
SenderID: "telegram:123",
|
SenderID: "telegram:123",
|
||||||
ChatID: "chat-1",
|
ChatID: "chat-1",
|
||||||
Content: "/reset",
|
Content: "/reset",
|
||||||
})); err != nil {
|
})); procErr != nil {
|
||||||
t.Fatalf("reset processMessage() error = %v", err)
|
t.Fatalf("reset processMessage() error = %v", procErr)
|
||||||
}
|
}
|
||||||
overrideSessionKey := al.getSessionOverride(routeSessionKey)
|
overrideSessionKey := al.getSessionOverride(routeSessionKey)
|
||||||
if overrideSessionKey == "" {
|
if overrideSessionKey == "" {
|
||||||
t.Fatal("expected override session key after /reset")
|
t.Fatal("expected override session key after /reset")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := al.processMessage(context.Background(), testInboundMessage(bus.InboundMessage{
|
if _, procErr := al.processMessage(context.Background(), testInboundMessage(bus.InboundMessage{
|
||||||
Channel: "telegram",
|
Channel: "telegram",
|
||||||
SenderID: "telegram:123",
|
SenderID: "telegram:123",
|
||||||
ChatID: "chat-1",
|
ChatID: "chat-1",
|
||||||
Content: "during reset",
|
Content: "during reset",
|
||||||
})); err != nil {
|
})); procErr != nil {
|
||||||
t.Fatalf("during-reset processMessage() error = %v", err)
|
t.Fatalf("during-reset processMessage() error = %v", procErr)
|
||||||
}
|
}
|
||||||
overrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
|
overrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
|
||||||
if overrideHistoryLen == 0 {
|
if overrideHistoryLen == 0 {
|
||||||
|
|
@ -849,7 +849,11 @@ func TestProcessMessage_ResetClearRestoresDefaultSession(t *testing.T) {
|
||||||
}
|
}
|
||||||
gotOverrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
|
gotOverrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
|
||||||
if gotOverrideHistoryLen != overrideHistoryLen {
|
if gotOverrideHistoryLen != overrideHistoryLen {
|
||||||
t.Fatalf("override history len = %d, want preserved len %d after reset clear", gotOverrideHistoryLen, overrideHistoryLen)
|
t.Fatalf(
|
||||||
|
"override history len = %d, want preserved len %d after reset clear",
|
||||||
|
gotOverrideHistoryLen,
|
||||||
|
overrideHistoryLen,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,11 @@ func (al *AgentLoop) resolveEffectiveSessionKey(routeSessionKey, msgSessionKey s
|
||||||
return routeSessionKey
|
return routeSessionKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func sessionAliasCandidates(routeSessionKey, effectiveSessionKey string, routeAliases []string, msgSessionKey string) []string {
|
func sessionAliasCandidates(
|
||||||
|
routeSessionKey, effectiveSessionKey string,
|
||||||
|
routeAliases []string,
|
||||||
|
msgSessionKey string,
|
||||||
|
) []string {
|
||||||
if isExplicitSessionKey(msgSessionKey) {
|
if isExplicitSessionKey(msgSessionKey) {
|
||||||
return []string{msgSessionKey}
|
return []string{msgSessionKey}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ type Runtime struct {
|
||||||
GetContextStats func() *ContextStats
|
GetContextStats func() *ContextStats
|
||||||
SwitchModel func(value string) (oldModel string, err error)
|
SwitchModel func(value string) (oldModel string, err error)
|
||||||
SwitchChannel func(value string) error
|
SwitchChannel func(value string) error
|
||||||
ResetSession func(clear bool) (sessionKey string, err error)
|
ResetSession func(clearOverride bool) (sessionKey string, err error)
|
||||||
ClearHistory func() error
|
ClearHistory func() error
|
||||||
ReloadConfig func() error
|
ReloadConfig func() error
|
||||||
StopActiveTurn func() (StopResult, error)
|
StopActiveTurn func() (StopResult, error)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue