check nil
This commit is contained in:
parent
2c6b335512
commit
a52fdb633f
2 changed files with 6 additions and 0 deletions
|
|
@ -1754,6 +1754,9 @@ func (al *AgentLoop) buildCommandsRuntime(agent *AgentInstance, opts *processOpt
|
|||
}
|
||||
|
||||
rt.ClearHistory = func() error {
|
||||
if opts == nil {
|
||||
return fmt.Errorf("process options not available")
|
||||
}
|
||||
if agent.Sessions == nil {
|
||||
return fmt.Errorf("sessions not initialized for agent")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ func clearCommand() Definition {
|
|||
Description: "Clear the chat history",
|
||||
Usage: "/clear",
|
||||
Handler: func(_ context.Context, req Request, rt *Runtime) error {
|
||||
if rt == nil || rt.ClearHistory == nil {
|
||||
return req.Reply(unavailableMsg)
|
||||
}
|
||||
if err := rt.ClearHistory(); err != nil {
|
||||
return req.Reply("Failed to clear chat history: " + err.Error())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue