CON-215: generatePosts fails soft on a past date instead of aborting the turn - #113
Conversation
…e turn A past (or otherwise invalid) publish window made the campaign assistant's generatePosts tool return a Go error, which aborts the whole Generate turn (CON-213) and surfaces to the user as a raw "model call failed: ... is in the past". The cheap planner also occasionally mis-routes into generatePosts, so a prompt-only guard isn't enough. Return a zero-post GeneratePostsOutput with the reason as a warning for every user-correctable input — past/invalid window, non-target platform, unknown phase — via softGenerateFailure, leaving generatedPostsResult unset so the turn stays conversational and the assistant suggests today or a later date. Genuine system errors still propagate. Reinforce the prompt to relay a zero-post warning as a suggestion, and add TestGeneratePosts_SoftFailsUserInput.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Walkthrough
ChangesCampaign post generation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change makes user-correctable scheduling inputs conversational instead of aborting the assistant turn while preserving genuine system errors; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
Problem
Picking a past publish date made the Campaign Assistant crash with a raw red error instead of recovering:
model call failed: tool "generatePosts" failed: error calling tool generatePosts:
2026-07-28 is in the past — choose 2026-07-29 (today) or a later date
Root cause:
generatePostsreturned a Goerrorfor a past window (resolveWindow). Per the genkit tool-loop semantics established in CON-213, a tool returning a Go error aborts the entireGenerateturn — it never reaches the model to be relayed — so it bubbled up throughrun.goasmodel call failed: ….A contributing factor is visible in the bug screenshots: the request was "review the brief", yet the cheap
RolePlanning(Haiku) planner mis-routed intogeneratePostsand ignored the prompt's existing past-date guard. A prompt-only guard therefore isn't enough — the tool itself must fail soft.Fix
toolGeneratePostsnow returns a zero-postGeneratePostsOutputcarrying the reason as awarningfor every user-correctable input — past/invalid window, non-target platform, unknown phase — via a newsoftGenerateFailurehelper, instead of a turn-aborting Go error.generatedPostsResultunset, sorun.gokeeps the turn conversational (answered) and the model's reply carries the suggestion. The warning text already contains "choose or a later date", giving the model the material to suggest a valid alternative — exactly what the issue asks for.TestGeneratePosts_SoftFailsUserInputcovering all three soft paths (asserts no error, zero posts + warning, generation engine not invoked, no result recorded).resolveWindow/resolvePhase/resolveTargetPlatformsare unchanged, so their existing unit tests stay green.Behavior change
model call failed: … is in the past(turn aborts)model call failed: … is not one of this campaign's target platformsmodel call failed: unknown phase …Testing
go build ./...go vet ./src/genkit/flows/campaign_assistant/go test ./src/genkit/flows/campaign_assistant/— all green, incl. the new testNotes / follow-up
post_assistant's scheduling path has the same crash class —scheduleToolErrorreturnsErrScheduledAtInPastas a Go error (post_assistant/tools.go:766). It's a separate flow and left out of this PR to keep it scoped to the reportedgeneratePostsbug; happy to fold in as a follow-up.Closes CON-215.
Summary by CodeRabbit