()
| 471 | } |
| 472 | |
| 473 | func (s *SubAgent) buildSystemPrompt() string { |
| 474 | if override, _ := s.ExtraContext["system_prompt_override"].(string); strings.TrimSpace(override) != "" { |
| 475 | return override |
| 476 | } |
| 477 | cwd := s.Config.CWD |
| 478 | if wt, _ := s.ExtraContext["worktree_cwd"].(string); wt != "" { |
| 479 | cwd = wt |
| 480 | } |
| 481 | gitContext := agentContext.GetGitContext(cwd, 3.0, true) |
| 482 | agentMemory := "" |
| 483 | if s.Config.LongTermMemoryEnabled { |
| 484 | agentMemory = s.longTermAgentMemoryBehavior() |
| 485 | } |
| 486 | sections, err := agentContext.BuildSubagentPromptSections(s.Definition.Name, s.Definition.Description, cwd, s.MaxTurns, gitContext, agentMemory) |
| 487 | if err == nil { |
| 488 | return agentContext.AssemblePromptSections(sections) |
| 489 | } |
| 490 | prompt := BuildSystemPrompt(cwd) + "\n\nSub-agent: " + s.Definition.Name + "\n" + s.Definition.Description |
| 491 | if agentMemory != "" { |
| 492 | prompt += agentMemory |
| 493 | } |
| 494 | return prompt |
| 495 | } |
| 496 | |
| 497 | func (s *SubAgent) buildInitialMessages(ctx context.Context, prompt string) []map[string]any { |
| 498 | var messages []map[string]any |
no test coverage detected