+ instructions, err := a.instructions()
+ if err != nil {
+ return "", fmt.Errorf("read prompt instructions: %w", err)
+ }
+
+ path, err := filepath.Abs(filepath.Join(a.dir, agentInstructionsFileName))
+ if err != nil {
+ return "", fmt.Errorf("find instructions path: %w", err)
+ }
+
+ return prompt(a.config.Name, path, instructions), nil
+}
+
+// SubagentPrompt returns the system prompt of a subagent of the agent, with the
+// user's instructions as Prompt reads them.
+func (a *Agent) SubagentPrompt() (string, error) {
+ instructions, err := a.instructions()
+ if err != nil {
+ return "", err
+ }
+
+ return promptSubagent(a.config.Name, instructions), nil
+}
+
+// instructions reads the user's instructions from instructions.md. A missing
+// file means no instructions.
+func (a *Agent) instructions() (string, error) {