fix(cli): satisfy reset command lint checks

This commit is contained in:
Anton Bogdanovich 2026-05-07 14:57:35 -07:00
parent af7bc26a58
commit 7d01b5d70a
5 changed files with 28 additions and 12 deletions

View file

@ -335,7 +335,7 @@ func (al *AgentLoop) buildCommandsRuntime(
return al.contextManager.Clear(ctx, opts.SessionKey)
}
rt.ResetSession = func(clear bool) (string, error) {
rt.ResetSession = func(clearOverride bool) (string, error) {
if opts == nil {
return "", fmt.Errorf("process options not available")
}
@ -343,7 +343,7 @@ func (al *AgentLoop) buildCommandsRuntime(
if routeSessionKey == "" {
return "", fmt.Errorf("route session key not available")
}
if clear {
if clearOverride {
return "", al.clearSessionOverride(routeSessionKey)
}

View file

@ -171,7 +171,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
Dispatch: DispatchRequest{
RouteSessionKey: allocation.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),
RouteResult: cloneResolvedRoute(&route),
SessionScope: session.CloneScope(&allocation.Scope),

View file

@ -792,26 +792,26 @@ func TestProcessMessage_ResetClearRestoresDefaultSession(t *testing.T) {
defaultAgent := al.GetRegistry().GetDefaultAgent()
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",
SenderID: "telegram:123",
ChatID: "chat-1",
Content: "/reset",
})); err != nil {
t.Fatalf("reset processMessage() error = %v", err)
})); procErr != nil {
t.Fatalf("reset processMessage() error = %v", procErr)
}
overrideSessionKey := al.getSessionOverride(routeSessionKey)
if overrideSessionKey == "" {
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",
SenderID: "telegram:123",
ChatID: "chat-1",
Content: "during reset",
})); err != nil {
t.Fatalf("during-reset processMessage() error = %v", err)
})); procErr != nil {
t.Fatalf("during-reset processMessage() error = %v", procErr)
}
overrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
if overrideHistoryLen == 0 {
@ -849,7 +849,11 @@ func TestProcessMessage_ResetClearRestoresDefaultSession(t *testing.T) {
}
gotOverrideHistoryLen := len(defaultAgent.Sessions.GetHistory(overrideSessionKey))
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,
)
}
}

View file

@ -49,7 +49,11 @@ func (al *AgentLoop) resolveEffectiveSessionKey(routeSessionKey, msgSessionKey s
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) {
return []string{msgSessionKey}
}

View file

@ -59,7 +59,7 @@ type Runtime struct {
GetContextStats func() *ContextStats
SwitchModel func(value string) (oldModel string, err 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
ReloadConfig func() error
StopActiveTurn func() (StopResult, error)