]> git.giacomolli.uk - onechat/blobdiff - turn.go
Stop a subagent with /stop NAME
[onechat] / turn.go
diff --git a/turn.go b/turn.go
index 02a4a28513d3b6419d24b1e1b5929e1652a6a315..3c1c921ec2d1df76e82fdda8188e3366df8b6c09 100644 (file)
--- a/turn.go
+++ b/turn.go
@@ -36,6 +36,7 @@ func newTurnLoop(agent *Agent, memory *Memory, subagents *Subagents, client Chai
                client:    client,
                state:     l.state,
                report:    l.Report,
                client:    client,
                state:     l.state,
                report:    l.Report,
+               note:      l.note,
                notify:    notify,
                running:   make(map[string]*SubagentRun),
        }
                notify:    notify,
                running:   make(map[string]*SubagentRun),
        }
@@ -133,6 +134,12 @@ func (l *TurnLoop) Report(text string, stopped bool) {
        }
 }
 
        }
 }
 
+// StopSubagent ends the run of the subagent name and tells if it ran. Its
+// report is logged, but it starts no turn.
+func (l *TurnLoop) StopSubagent(name string) (bool, error) {
+       return l.runs.Stop(name)
+}
+
 // Interrupt ends the running turn. A running tool is killed, and the turn sends
 // no further request.
 func (l *TurnLoop) Interrupt() bool {
 // Interrupt ends the running turn. A running tool is killed, and the turn sends
 // no further request.
 func (l *TurnLoop) Interrupt() bool {
@@ -194,6 +201,13 @@ func (l *TurnLoop) Run(ctx context.Context) error {
        }
 }
 
        }
 }
 
+// note logs a note and tells the clients. A note starts no turn.
+func (l *TurnLoop) note(text string) error {
+       _, err := l.record("note", "", text)
+
+       return err
+}
+
 // record logs a message and tells the clients, with the client source of a user
 // message.
 func (l *TurnLoop) record(kind, source, text string) (Message, error) {
 // record logs a message and tells the clients, with the client source of a user
 // message.
 func (l *TurnLoop) record(kind, source, text string) (Message, error) {