fix: retry invalid AI summary generation#208
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAIService repository analysis now validates AI-generated summaries across up to three retry attempts, using a new sanitization pipeline to reject meta-text and instruction-like content while stricter prompts forbid restatement phrases in both Chinese and English. ChangesAI Repository Analysis Validation
Sequence DiagramsequenceDiagram
participant Caller
participant analyzeRepository
participant requestText
participant parseAIResponse
Caller->>analyzeRepository: analyzeRepository()
loop up to ANALYSIS_MAX_ATTEMPTS
analyzeRepository->>requestText: request AI output (with retry prompt if needed)
requestText-->>analyzeRepository: raw AI response
analyzeRepository->>parseAIResponse: parse and validate
parseAIResponse-->>analyzeRepository: { isValid, summary, tags, platforms, invalidReason }
alt isValid
analyzeRepository-->>Caller: return { summary, tags, platforms }
else attempt < MAX
Note over analyzeRepository: record invalidReason, retry
else final attempt failed
analyzeRepository-->>Caller: throw language-specific error
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/aiService.ts`:
- Around line 701-770: sanitizeSummary currently strips known prompt-restatement
prefixes (metaPrefixes) and returns the remainder, which lets parseAIResponse
accept summaries like "We were asked... A CLI backup tool." — instead, treat any
text that had a meta-prefix as invalid so parseAIResponse/analyzeRepository will
retry/fail. Update sanitizeSummary (and its metaPrefixes logic and use of
isMetaText) to detect when cleaning removed a meta-prefix (e.g., compare the
original trimmed raw to the final cleaned or check if any metaPrefixes matched)
and return null in that case rather than returning the salvaged remainder; keep
other validation (length, punctuation-only, hardMetaPatterns) intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ec054eaa-75f1-4a29-8af4-c72dca99ef6d
📒 Files selected for processing (2)
src/components/settings/AIConfigPanel.tsxsrc/services/aiService.ts
2700847 to
5b6d9a8
Compare
针对返回思考内容: #174
Summary
修复 AI 仓库分析中
summary不符合要求仍被保存的问题。当模型把提示词要求复述到
summary中时,不再保存占位内容,而是重新生成符合要求的结果。Changes
summary校验,拦截“我们被要求”“只输出JSON”“根据仓库信息”“summary/tags/platforms”等提示词复述内容。summary不合规时,自动重试生成。summary只能描述仓库功能和用途。Summary by CodeRabbit
Bug Fixes
Other