Skip to content

Commit 1582a4e

Browse files
Fix insights guideline budget cap and branch-exclusion logic
- Change guideline cap from max(budget/10, 1024) to min(budget/10, 1024) so guidelines cannot exceed the prompt budget for small max_prompt_size. - Exempt insights jobs from branch-exclusion unless an explicit --branch filter was provided, since insights is read-only historical analysis. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 376e27b commit 1582a4e

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

cmd/roborev/insights.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func runInsights(cmd *cobra.Command, opts insightsOptions) error {
145145
})
146146

147147
ep := getDaemonEndpoint()
148-
resp, err := ep.HTTPClient(30 * time.Second).Post(ep.BaseURL()+"/api/enqueue", "application/json", bytes.NewReader(reqBody))
148+
resp, err := ep.HTTPClient(30*time.Second).Post(ep.BaseURL()+"/api/enqueue", "application/json", bytes.NewReader(reqBody))
149149
if err != nil {
150150
return fmt.Errorf("failed to connect to daemon: %w", err)
151151
}

internal/daemon/server.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,15 @@ func (s *Server) handleEnqueue(w http.ResponseWriter, r *http.Request) {
710710

711711
// Check if branch is excluded from reviews
712712
currentBranch := git.GetCurrentBranch(gitCwd)
713-
branchForJob := currentBranch
714-
if req.Branch != "" {
715-
branchForJob = req.Branch
716-
}
717713
branchToCheck := currentBranch
718714
if req.JobType == storage.JobTypeInsights {
719-
branchToCheck = branchForJob
715+
// Insights is read-only historical analysis — only apply branch
716+
// exclusion when an explicit branch filter was provided.
717+
if req.Branch != "" {
718+
branchToCheck = req.Branch
719+
} else {
720+
branchToCheck = ""
721+
}
720722
}
721723
if branchToCheck != "" && config.IsBranchExcluded(repoRoot, branchToCheck) {
722724
// Silently skip excluded branches - return 200 OK with skipped flag

internal/prompt/insights.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func BuildInsightsPrompt(data InsightsData) string {
9595
sb.WriteString("## Current Review Guidelines\n\n")
9696
if data.Guidelines != "" {
9797
guidelines := data.Guidelines
98-
guidelineCap := max(promptBudget/10, 1024)
98+
guidelineCap := min(promptBudget/10, 1024)
9999
if len(guidelines) > guidelineCap {
100100
guidelines = guidelines[:guidelineCap] + "\n... (guidelines truncated)"
101101
}

0 commit comments

Comments
 (0)