| 735 | if !enabled { |
| 736 | return PromptSection{}, errors.New("session memory disabled") |
| 737 | } |
| 738 | return PromptSection{ |
| 739 | "session-memory-behavior", |
| 740 | sessionMemorySection, |
| 741 | true, |
| 742 | }, nil |
| 743 | } |
| 744 | |
| 745 | func BuildSubagentIdentitySection(agentName, description string) PromptSection { |
| 746 | content := fmt.Sprintf( |
| 747 | "You are a %s sub-agent. %s", agentName, description) |
| 748 | return PromptSection{"subagent-identity", content, false} |
| 749 | } |
| 750 | |
| 751 | func BuildSubagentExecutionConstraintsSection(maxTurns int) PromptSection { |
| 752 | content := fmt.Sprintf( |
| 753 | "Instructions:\n"+ |
| 754 | "- Complete the assigned task and return a concise result.\n"+ |
| 755 | "- You have access to a limited set of tools - use them wisely.\n"+ |
| 756 | "- You have %d turns to complete the task.\n"+ |
| 757 | "- Return your final answer as plain text; the parent agent will use it to continue its work.", |
| 758 | maxTurns, |
| 759 | ) |
| 760 | return PromptSection{"subagent-execution-constraints", content, false} |
| 761 | } |
| 762 | |
| 763 | func BuildSubagentPromptSections(agentName, description, cwd string, maxTurns int, gitContext, agentMemory string) ([]PromptSection, error) { |
| 764 | priority, err := BuildInstructionPrioritySection() |
| 765 | if err != nil { |
| 766 | return nil, err |
| 767 | } |
| 768 | trust, err := BuildTrustAndExternalContextSection() |
| 769 | if err != nil { |
| 770 | return nil, err |
| 771 | } |
| 772 | workflow, err := BuildWorkflowSection() |
| 773 | if err != nil { |
| 774 | return nil, err |