]> git.giacomolli.uk - onechat/blobdiff - tools.go
Send messages to subagents with tell
[onechat] / tools.go
index 737618e91bd77851ebda0d658ca9dec0cda4d4a7..dd28ae03af98ed306f6fbe9b86bf2489c3c43ac2 100644 (file)
--- a/tools.go
+++ b/tools.go
@@ -50,8 +50,9 @@ type ToolChat interface {
 // message. The call is durable before its tool runs, so the log never misses an
 // action outside the agent. Commands and files run as the user in the working
 // directory, with no sandbox. Zoom with a name reads the log of a subagent.
 // message. The call is durable before its tool runs, so the log never misses an
 // action outside the agent. Commands and files run as the user in the working
 // directory, with no sandbox. Zoom with a name reads the log of a subagent.
-// The toolbox of the agent has the runs of its subagents for spawn. The
-// toolbox of a subagent has none, so spawn is an unknown tool there.
+// The toolbox of the agent has the runs of its subagents for spawn and tell.
+// The toolbox of a subagent has none, so spawn and tell are unknown tools
+// there.
 type Toolbox struct {
        log       ToolLog
        chat      ToolChat
 type Toolbox struct {
        log       ToolLog
        chat      ToolChat
@@ -142,6 +143,15 @@ func (b *Toolbox) run(ctx context.Context, name, arguments string) string {
                case err == nil:
                        output, err = b.runs.Spawn(ctx, args.Tasks, args.Effort)
                }
                case err == nil:
                        output, err = b.runs.Spawn(ctx, args.Tasks, args.Effort)
                }
+       case "tell":
+               var args ToolTellArguments
+               err = toolDecodeArguments(arguments, &args)
+               switch {
+               case b.runs == nil:
+                       err = fmt.Errorf("unknown tool %q", name)
+               case err == nil:
+                       output, err = b.runs.Tell(ctx, args.Name, args.Message)
+               }
        default:
                err = fmt.Errorf("unknown tool %q", name)
        }
        default:
                err = fmt.Errorf("unknown tool %q", name)
        }
@@ -377,6 +387,12 @@ type ToolSpawnArguments struct {
        Effort *string  `json:"effort"`
 }
 
        Effort *string  `json:"effort"`
 }
 
+// ToolTellArguments are the arguments of tell.
+type ToolTellArguments struct {
+       Name    string `json:"name"`
+       Message string `json:"message"`
+}
+
 // ToolHeadTail keeps the first and the last toolClipBytes bytes written to it,
 // and counts the bytes between them that it drops.
 type ToolHeadTail struct {
 // ToolHeadTail keeps the first and the last toolClipBytes bytes written to it,
 // and counts the bytes between them that it drops.
 type ToolHeadTail struct {