feat: show model in new session reply

This commit is contained in:
Jaron Swab 2026-02-21 17:44:14 -05:00
parent 4949ad9961
commit 148015ba0d
2 changed files with 75 additions and 3 deletions

View file

@ -462,7 +462,41 @@ func (al *AgentLoop) startNewSessionForMessage(msg bus.InboundMessage) (string,
overrideKey := buildSessionOverrideKey(msg.Channel, msg.ChatID, agent.ID)
al.sessionOverride.Set(overrideKey, newSessionKey)
return "Starting a new conversation...", nil
return formatNewSessionResponse(al.cfg, agent), nil
}
func formatNewSessionResponse(cfg *config.Config, agent *AgentInstance) string {
provider, model := resolveAgentModelDisplay(cfg, agent)
if model == "" {
return "Starting a new conversation..."
}
if provider == "" {
return fmt.Sprintf("Starting a new conversation... (model: %s)", model)
}
return fmt.Sprintf("Starting a new conversation... (provider: %s, model: %s)", provider, model)
}
func resolveAgentModelDisplay(cfg *config.Config, agent *AgentInstance) (string, string) {
if agent == nil {
return "", ""
}
modelName := strings.TrimSpace(agent.Model)
if modelName == "" {
return "", ""
}
if cfg != nil {
if modelCfg, err := cfg.GetModelConfig(modelName); err == nil && modelCfg != nil {
if ref := providers.ParseModelRef(modelCfg.Model, ""); ref != nil {
return ref.Provider, ref.Model
}
return "", strings.TrimSpace(modelCfg.Model)
}
}
ref := providers.ParseModelRef(modelName, "")
if ref == nil {
return "", modelName
}
return ref.Provider, ref.Model
}
// runAgentLoop is the core message processing logic.

View file

@ -401,7 +401,7 @@ func TestNewSessionCommand_SuccessAndIsolation(t *testing.T) {
ChatID: "chat1",
Content: "/new",
})
if response != "Starting a new conversation..." {
if response != "Starting a new conversation... (model: test-model)" {
t.Fatalf("Expected confirmation response, got %q", response)
}
@ -435,6 +435,44 @@ func TestNewSessionCommand_SuccessAndIsolation(t *testing.T) {
}
}
func TestNewSessionCommand_IncludesProviderWhenPrefixed(t *testing.T) {
provider := &simpleMockProvider{response: "OK"}
tmpDir, err := os.MkdirTemp("", "agent-test-*")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
cfg := &config.Config{
Agents: config.AgentsConfig{
Defaults: config.AgentDefaults{
Workspace: tmpDir,
Model: "openai/gpt-5.2",
MaxTokens: 4096,
MaxToolIterations: 10,
},
},
}
msgBus := bus.NewMessageBus()
al := NewAgentLoop(cfg, msgBus, provider)
if al.registry.GetDefaultAgent() == nil {
t.Fatal("No default agent found")
}
helper := testHelper{al: al}
ctx := context.Background()
response := helper.executeAndGetResponse(t, ctx, bus.InboundMessage{
Channel: "test",
SenderID: "user1",
ChatID: "chat1",
Content: "/new",
})
if response != "Starting a new conversation... (provider: openai, model: gpt-5.2)" {
t.Fatalf("Expected confirmation response, got %q", response)
}
}
func TestNewSessionCommand_RejectsArgs(t *testing.T) {
provider := &simpleMockProvider{response: "OK"}
al, tmpDir := newTestAgentLoop(t, provider)
@ -526,7 +564,7 @@ func TestNewSessionCommand_NoCrossChatImpact(t *testing.T) {
"peer_id": "group1",
},
})
if response != "Starting a new conversation..." {
if response != "Starting a new conversation... (model: test-model)" {
t.Fatalf("Expected confirmation response, got %q", response)
}