]> git.giacomolli.uk - onechat/blobdiff - prompt.go
Run each child with its own files and loop
[onechat] / prompt.go
index e651988105b1aedd49d5dd775ccd412cf44c5639..934491f3e642cf5b3842430009ab1de110f47f0f 100644 (file)
--- a/prompt.go
+++ b/prompt.go
@@ -188,13 +188,33 @@ whole chat.`
 // cache of the turns.
 func prompt(name, instructionsPath, instructions string) string {
        text := strings.NewReplacer(promptName, name, promptInstructionsPath, instructionsPath).Replace(promptText)
 // cache of the turns.
 func prompt(name, instructionsPath, instructions string) string {
        text := strings.NewReplacer(promptName, name, promptInstructionsPath, instructionsPath).Replace(promptText)
+
        return promptWithInstructions(text, promptTaskSentence, promptInstructionsClause, instructions)
 }
 
        return promptWithInstructions(text, promptTaskSentence, promptInstructionsClause, instructions)
 }
 
+// promptChild returns the prompt of a child with its area and reporting rules.
+// Its instructions file belongs to the child, not to the parent.
+func promptChild(name, parent, responsibility, instructionsPath, instructions string) string {
+       text := prompt(name, instructionsPath, "")
+       text = strings.Replace(text, "You are "+name+", an AI agent that works for one user in a single chat that never\nends.", "You are "+name+", a child agent of "+parent+".", 1)
+       text = strings.Replace(text, promptTaskSentence, `Do the tasks of your area yourself, with your tools.
+You are responsible for: `+responsibility+`
+Work only in this area. Report to `+parent+` only what needs the parent or the
+user: a decision, a deadline, a problem, a question you cannot settle, or a
+message outside your area. Your final reply is your report to the parent.
+End your turn with an empty reply when nothing needs the parent or the user.
+Send nothing to WhatsApp. Draft replies in your report instead, so the parent
+can ask the user before sending.`, 1)
+       text = strings.Replace(text, "You act again only when the user writes.", "You act again when a message or your own schedule wakes you.", 1)
+
+       return promptWithInstructions(text, "Do the tasks of your area yourself, with your tools.", promptInstructionsClause, instructions)
+}
+
 // promptSubagent returns the system prompt of a subagent of the agent name,
 // with the instructions of the user at its end, as prompt does.
 func promptSubagent(name, instructions string) string {
        text := strings.ReplaceAll(promptSubagentText, promptName, name)
 // promptSubagent returns the system prompt of a subagent of the agent name,
 // with the instructions of the user at its end, as prompt does.
 func promptSubagent(name, instructions string) string {
        text := strings.ReplaceAll(promptSubagentText, promptName, name)
+
        return promptWithInstructions(text, promptSubagentTaskSentence, promptSubagentInstructionsClause, instructions)
 }
 
        return promptWithInstructions(text, promptSubagentTaskSentence, promptSubagentInstructionsClause, instructions)
 }