Skip to content

Commit 5d34079

Browse files
wesmclaude
andauthored
Add Gemini-specific preamble for run tasks (#121)
## Summary - Gemini tends to be verbose and explain its process when running tasks, which clutters output - Adds a `gemini_run.tmpl` template with the same professional/concise preamble used for reviews - The worker now prepends agent-specific preambles to prompt jobs ## Changes - Create `gemini_run.tmpl` template with concise instructions - Export `GetSystemPrompt` for use by worker - Update worker to prepend agent preamble to prompt jobs - Add test for Gemini run template loading ## Test plan - [x] Run `roborev run "explain this codebase" --agent gemini` and verify output is concise without inner monologue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a748f41 commit 5d34079

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

internal/daemon/worker.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,13 @@ func (wp *WorkerPool) processJob(workerID string, job *storage.ReviewJob) {
256256
var reviewPrompt string
257257
var err error
258258
if job.GitRef == "prompt" && job.Prompt != "" {
259-
// Custom prompt job - use pre-stored prompt directly
260-
reviewPrompt = job.Prompt
259+
// Custom prompt job - prepend agent-specific preamble if available
260+
preamble := prompt.GetSystemPrompt(job.Agent, "run")
261+
if preamble != "" {
262+
reviewPrompt = preamble + "\n" + job.Prompt
263+
} else {
264+
reviewPrompt = job.Prompt
265+
}
261266
} else if job.DiffContent != nil {
262267
// Dirty job - use pre-captured diff
263268
reviewPrompt, err = wp.promptBuilder.BuildDirty(job.RepoPath, *job.DiffContent, job.RepoID, cfg.ReviewContextCount, job.Agent)

internal/prompt/prompt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (b *Builder) BuildDirty(repoPath, diff string, repoID int64, contextCount i
136136
var sb strings.Builder
137137

138138
// Start with system prompt for dirty changes
139-
sb.WriteString(getSystemPrompt(agentName, "dirty"))
139+
sb.WriteString(GetSystemPrompt(agentName, "dirty"))
140140
sb.WriteString("\n")
141141

142142
// Add project-specific guidelines if configured
@@ -195,7 +195,7 @@ func (b *Builder) buildSinglePrompt(repoPath, sha string, repoID int64, contextC
195195
var sb strings.Builder
196196

197197
// Start with system prompt
198-
sb.WriteString(getSystemPrompt(agentName, "review"))
198+
sb.WriteString(GetSystemPrompt(agentName, "review"))
199199
sb.WriteString("\n")
200200

201201
// Add project-specific guidelines if configured
@@ -272,7 +272,7 @@ func (b *Builder) buildRangePrompt(repoPath, rangeRef string, repoID int64, cont
272272
var sb strings.Builder
273273

274274
// Start with system prompt for ranges
275-
sb.WriteString(getSystemPrompt(agentName, "range"))
275+
sb.WriteString(GetSystemPrompt(agentName, "range"))
276276
sb.WriteString("\n")
277277

278278
// Add project-specific guidelines if configured
@@ -508,7 +508,7 @@ func (b *Builder) BuildAddressPrompt(repoPath string, review *storage.Review, pr
508508
var sb strings.Builder
509509

510510
// System prompt
511-
sb.WriteString(getSystemPrompt(review.Agent, "address"))
511+
sb.WriteString(GetSystemPrompt(review.Agent, "address"))
512512
sb.WriteString("\n")
513513

514514
// Add project-specific guidelines if configured

internal/prompt/templates.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import (
99
//go:embed templates/*.tmpl
1010
var templateFS embed.FS
1111

12-
// getSystemPrompt returns the system prompt for the specified agent and type.
12+
// GetSystemPrompt returns the system prompt for the specified agent and type.
1313
// If a specific template exists for the agent, it uses that.
1414
// Otherwise, it falls back to the default constant.
15-
func getSystemPrompt(agentName string, promptType string) string {
15+
// Supported prompt types: review, range, dirty, address, run
16+
func GetSystemPrompt(agentName string, promptType string) string {
1617
// Normalize agent name
1718
agentName = strings.ToLower(agentName)
1819
if agentName == "claude" {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
You are a helpful assistant working on a software project.
2+
3+
Your goal is to be extremely concise and professional. Do NOT explain your process, list the steps you are taking, or provide unnecessary commentary. Just provide the results directly.
4+
5+
Focus on:
6+
- Answering questions directly and accurately
7+
- Providing code examples when helpful
8+
- Being practical and actionable
9+

internal/prompt/templates_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
func TestGeminiTemplateLoads(t *testing.T) {
9-
result := getSystemPrompt("gemini", "review")
9+
result := GetSystemPrompt("gemini", "review")
1010
if result == SystemPromptSingle {
1111
t.Error("Expected Gemini-specific template, got default SystemPromptSingle")
1212
}
@@ -17,9 +17,9 @@ func TestGeminiTemplateLoads(t *testing.T) {
1717

1818
func TestAgentTemplatesFallbackToReview(t *testing.T) {
1919
// Range and dirty should use the same template as review
20-
review := getSystemPrompt("gemini", "review")
21-
rang := getSystemPrompt("gemini", "range")
22-
dirty := getSystemPrompt("gemini", "dirty")
20+
review := GetSystemPrompt("gemini", "review")
21+
rang := GetSystemPrompt("gemini", "range")
22+
dirty := GetSystemPrompt("gemini", "dirty")
2323

2424
if rang != review {
2525
t.Error("Expected range to use same template as review")
@@ -28,3 +28,13 @@ func TestAgentTemplatesFallbackToReview(t *testing.T) {
2828
t.Error("Expected dirty to use same template as review")
2929
}
3030
}
31+
32+
func TestGeminiRunTemplateLoads(t *testing.T) {
33+
result := GetSystemPrompt("gemini", "run")
34+
if result == "" {
35+
t.Error("Expected Gemini run template to load")
36+
}
37+
if !strings.Contains(result, "Do NOT explain your process") {
38+
t.Errorf("Expected Gemini run template content, got: %s", result[:min(100, len(result))])
39+
}
40+
}

0 commit comments

Comments
 (0)