diff --git a/apps/server/src/textGeneration/TextGenerationPrompts.ts b/apps/server/src/textGeneration/TextGenerationPrompts.ts index a7227ae37a..ba1e55b74d 100644 --- a/apps/server/src/textGeneration/TextGenerationPrompts.ts +++ b/apps/server/src/textGeneration/TextGenerationPrompts.ts @@ -252,7 +252,13 @@ export function buildThreadReviewPrompt(input: ThreadReviewPromptInput) { "Return a JSON object with keys: summary, nextStep, suggestedTitle, recommendSettle, settleReason.", "Rules:", "- summary: ONE sentence, max ~25 words: what was asked and where it landed", - "- nextStep: ONE short imperative sentence with the user's single next action (e.g. 'Review and merge PR #123.', 'Answer the agent's question about auth scopes.', 'Nothing left — settle this thread.')", + "- nextStep: a COMMAND to the user, max 10 words. Start with a verb. Never describe status.", + " GOOD: 'Merge PR #4415.'", + " GOOD: 'Answer the agent's question about auth scopes.'", + " GOOD: 'Settle this thread.'", + " GOOD: 'Wait — agent still working.'", + " BAD: 'The requested comparison and hosted write-up are complete, and...' (status recap, not a command)", + " BAD: 'You should probably consider reviewing the PR when you have time.' (hedging filler)", "- suggestedTitle: a corrected 3-8 word title ONLY if the current title is misleading or a placeholder like 'New thread'; otherwise null", "- recommendSettle: true ONLY when the work clearly concluded (done, abandoned, or superseded) and nothing awaits the user", "- settleReason: one short sentence justifying recommendSettle, or null when recommendSettle is false", diff --git a/apps/server/src/textGeneration/TextGenerationUtils.ts b/apps/server/src/textGeneration/TextGenerationUtils.ts index 7a57c23a0f..7bffe422ab 100644 --- a/apps/server/src/textGeneration/TextGenerationUtils.ts +++ b/apps/server/src/textGeneration/TextGenerationUtils.ts @@ -85,7 +85,18 @@ export function normalizeThreadReview( settleReason: string | null; } { const summary = raw.summary.trim().replace(/\s+/g, " "); - const nextStep = raw.nextStep.trim().replace(/\s+/g, " "); + // Backstop against rambling: first sentence only, hard-capped. The prompt + // asks for a <=10-word command, but models drift — never render a recap. + const nextStepFirstSentence = + raw.nextStep + .trim() + .replace(/\s+/g, " ") + .match(/^[^.!?]*[.!?]?/)?.[0] + ?.trim() ?? ""; + const nextStep = + nextStepFirstSentence.length > 80 + ? `${nextStepFirstSentence.slice(0, 77).trimEnd()}...` + : nextStepFirstSentence; const suggestedTitle = raw.suggestedTitle && raw.suggestedTitle.trim().length > 0 ? sanitizeThreadTitle(raw.suggestedTitle) diff --git a/apps/web/src/components/reviewSweep/ReviewSweepView.tsx b/apps/web/src/components/reviewSweep/ReviewSweepView.tsx index 6655c23bb0..f11c8025cc 100644 --- a/apps/web/src/components/reviewSweep/ReviewSweepView.tsx +++ b/apps/web/src/components/reviewSweep/ReviewSweepView.tsx @@ -222,12 +222,16 @@ function SweepItemCard({ ) : null; // The one-line "what should I do" is the card body; the full summary - // lives behind the info icon so the grid stays scannable. - const nextStep = - item.status === "error" - ? null - : (result?.nextStep ?? - (bucket === "settle" && result?.settleReason ? result.settleReason : null)); + // lives behind the info icon so the grid stays scannable. Results from + // pre-nextStep servers fall back to settleReason (settle bucket) or the + // summary (attention bucket) so action cards never render bodyless. + const nextStepFallback = + bucket === "settle" + ? (result?.settleReason ?? null) + : bucket === "attention" + ? (result?.summary ?? null) + : null; + const nextStep = item.status === "error" ? null : (result?.nextStep ?? nextStepFallback); return (