Skip to content

Commit 2d2cd2f

Browse files
jahoomaclaude
andcommitted
Lead bot-sweep email with agent review, include in API response
The agent's tiered recommendation is the actionable part — surface it above the raw rule-based data in the email. Also return the full agent review text in the API JSON response so the GitHub Action can log it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 1c30243 commit 2d2cd2f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

scripts/test-bot-sweep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function main() {
4545
console.log('\n--- END ---')
4646

4747
const fullMessage = agentReview
48-
? `${message}\n\n=== AGENT REVIEW (Claude Sonnet 4.6) ===\n\n${agentReview}`
48+
? `=== AGENT REVIEW (Claude Sonnet 4.6) ===\n\n${agentReview}\n\n=== RAW RULE-BASED DATA ===\n\n${message}`
4949
: message
5050

5151
console.log(`\nSending email to ${RECIPIENT}…`)

web/src/app/api/admin/bot-sweep/route.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ export async function POST(req: NextRequest) {
4646
const { subject, message } = formatSweepReport(report)
4747

4848
// Second-pass agent review. Advisory only — if it fails or returns
49-
// null we still send the rule-based report.
49+
// null we still send the rule-based report. Lead with the agent's
50+
// tiered recommendation since that's the actionable part; raw
51+
// rule-based data follows as supporting detail.
5052
const agentReview = await reviewSuspects({ report, logger })
5153
const fullMessage = agentReview
52-
? `${message}\n\n=== AGENT REVIEW (Claude Sonnet 4.6) ===\n\n${agentReview}`
54+
? `=== AGENT REVIEW (Claude Sonnet 4.6) ===\n\n${agentReview}\n\n=== RAW RULE-BASED DATA ===\n\n${message}`
5355
: message
5456

5557
const emailResult = await sendBasicEmail({
@@ -71,7 +73,7 @@ export async function POST(req: NextRequest) {
7173
suspectCount: report.suspects.length,
7274
highTierCount: report.suspects.filter((s) => s.tier === 'high').length,
7375
emailSent: emailResult.success,
74-
agentReviewIncluded: agentReview !== null,
76+
agentReview,
7577
})
7678
} catch (error) {
7779
logger.error({ error }, 'bot-sweep failed')

0 commit comments

Comments
 (0)