X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/e1e48ba388c28105fff3b70c8ca02304f5d57f53..47f69638bc96100f2e446f63c7c3689023156e64:/turn.go?ds=sidebyside diff --git a/turn.go b/turn.go index 02a4a28..3c1c921 100644 --- 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, + note: l.note, 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 { @@ -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) {