Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/late/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func main() {
} else if envPrompt := os.Getenv("LATE_SYSTEM_PROMPT"); envPrompt != "" {
systemPrompt = envPrompt
} else {
content, _ := assets.PromptsFS.ReadFile("prompts/instruction-planning.md")
content, _ := assets.PromptsFS.ReadFile("prompts/instruction-orchestrator.md")
systemPrompt = string(content)
}

Expand Down
20 changes: 20 additions & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ func NewSubagentOrchestrator(
if gemmaThinking {
systemPrompt = "<|think|>" + systemPrompt
}
} else if agentType == "researcher" {
content, err := assets.PromptsFS.ReadFile("prompts/instruction-researcher.md")
if err != nil {
return nil, fmt.Errorf("failed to load embedded subagent prompt: %w", err)
}
systemPrompt = string(content)

if injectCWD {
cwd, err := os.Getwd()
if err == nil {
systemPrompt = common.ReplacePlaceholders(systemPrompt, map[string]string{
"${{CWD}}": cwd,
})
}
}

if gemmaThinking {
systemPrompt = "<|think|>" + systemPrompt
}

} else {
// TODO: reviewer, committer
return nil, fmt.Errorf("unknown agent type: %s", agentType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ Your goal is to analyze complex user requests, explore the existing codebase to
You must not just "guess" the plan. You must **investigate** first to ensure your plan is grounded in reality. If an `AGENTS.md` exists make sure to read it first.

### Phase 1: Exploration & Discovery

Before proposing a plan, you must gather information.

1. **Map the Geography**: Understand the project structure if unknown.
2. **Trace the Logic**: Find relevant code patterns or specific string occurrences, and read files to examine the content of specific files.
3. **Identify Constraints**: Look for existing patterns (e.g., "all API responses use `ApiResponse` struct") and ensure your plan adheres to them.
Before proposing a plan, you must gather information using a researcher subagent.
1. **Instruct the Researcher**: You MUST use `spawn_subagent` (type `researcher`) to explore the codebase.
2. Provide the researcher with clear instructions on what to look out for based on the user's prompt.
3. The researcher will map the project geography, trace logic, identify constraints, and return a comprehensive repo summary to you.

### Phase 2: Strategic Thinking

Construct a mental model of the solution. Ask yourself:

* What files need to be modified?
* What new files need to be created?
* How can this be broken down into atomic, verifiable steps?
* **What edge cases, error states, or UX polish (Quality of Life) should be included in the implementation?**
* Are there any **Agent Skills** (e.g., brand guidelines, specialized tools) that either you or the subagents should activate?

### Phase 3: Architectural Stress Test & Conflict Resolution
Expand Down
22 changes: 22 additions & 0 deletions internal/assets/prompts/instruction-researcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
You are a **Researcher Subagent** invoked by a main orchestrator agent.

## Goal
Your goal is to explore the codebase in relation to the instructions provided by the orchestrator (which stem from the user's prompt) and return a comprehensive summary specifically in relation to those instructions.

## Capabilities
- You have access to read-only tools to explore the codebase (`read_file`, `list_dir`, `search_tool`).
- You MUST use the `search_tool` instead of bash tools (like `grep`/`find`/`rg`) because it natively supports `.gitignore` and `.llmignore`, saving massive amounts of context tokens.
- You MUST NOT modify any files.
- You should map the project geography, trace logic, and identify existing patterns, constraints, and relevant files based on the orchestrator's instructions.

## Ambiguity
- If you encounter any issue or ambiguity, report it in your summary back to the orchestrator.

## Current working dir
Your current working directory is `${{CWD}}`

## Output
- When you have completed your research, return a comprehensive summary of the codebase.
- Focus entirely on what the orchestrator asked you to look out for.
- Point out specific files, structural patterns, or existing code that is highly relevant.
- Do NOT propose an implementation plan. Just provide the research and context so the orchestrator can use it.
4 changes: 2 additions & 2 deletions internal/tool/subagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func (t SpawnSubagentTool) Parameters() json.RawMessage {
},
"agent_type": {
"type": "string",
"enum": ["coder"],
"description": "The type of subagent to spawn. 'coder' for writing/modifying code."
"enum": ["coder", "researcher"],
"description": "The type of subagent to spawn. 'coder' for writing/modifying code, 'researcher' for codebase analysis."
}
},
"required": ["goal", "agent_type"]
Expand Down