Files
picoclaw/pkg/commands/cmd_new.go
T
loveuer a7dba6859b feat: support fresh IM sessions and OpenAI reasoning controls
支持 /new 清空会话或携带新问题执行,忙碌时拒绝并保留原任务状态。
修复路由会话隔离及旧摘要回写,完善 OpenAI reasoning.effort 和 temperature 处理。
补充中英文文档与测试;相关包回归、race、lint 和 Gateway 构建通过。
2026-11-11 11:26:23 +08:00

31 lines
710 B
Go

package commands
import (
"context"
"strings"
"unicode"
)
func newCommand() Definition {
return Definition{
Name: "new",
Description: "Clear the chat history and optionally run a new prompt",
Usage: "/new [prompt]",
Handler: func(ctx context.Context, req Request, rt *Runtime) error {
if rt == nil || rt.StartNewConversation == nil {
return req.Reply(unavailableMsg)
}
text := strings.TrimSpace(req.Text)
var prompt string
if i := strings.IndexFunc(text, unicode.IsSpace); i >= 0 {
prompt = strings.TrimSpace(text[i:])
}
response, err := rt.StartNewConversation(ctx, prompt)
if err != nil {
return err
}
return req.Reply(response)
},
}
}