feat(prompt): optimize booking flow with tool chaining, ASAP auto-select, and structured errors#45
Conversation
…ect, and structured errors
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Deployment failed with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/chat/lib/agent.ts">
<violation number="1" location="apps/chat/lib/agent.ts:795">
P2: The fallback string `"Failed to fetch event types for this user"` contains `"fetch"`, so `isNetwork` is always `true` when `err` is not an `Error` instance. This misclassifies unknown errors as transient network failures, giving the agent a misleading retry hint.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/chat/lib/agent.ts">
<violation number="1" location="apps/chat/lib/agent.ts:1130">
P2: Generic fetch failures are no longer classified as retryable network errors in the booking tools.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/chat/lib/agent.ts">
<violation number="1" location="apps/chat/lib/agent.ts:795">
P2: This narrower check stops retryable Cal.com lookup failures from being recognized, so transient 5xx errors get reported to the agent as an invalid username.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
feat(prompt): optimize booking flow with tool chaining and ASAP auto-select
Summary
Rewrites the booking section of the agent system prompt in
lib/agent.tsto minimize user round-trips (from 4 messages → 2 for the best case). Also adds structured error hints to tool returns so the agent can react more intelligently to failures.Prompt changes (
getSystemPrompt()):list_event_types→check_availability→ text) instead of stopping after each tool.slots[0]for ASAP requests instead of presenting 3-5 options. UsesnextAvailableSlotsfrom the extended search when 0 slots found in 3 days.Tool return changes:
list_event_types_by_username: AddsfallbackSuggestionon 0 results andretryable+fallbackSuggestionon errors.book_meeting/book_meeting_public: Addsretryableandsuggestionfields for 409 conflicts and network errors.Review & Testing Checklist for Human
These are prompt-engineering changes — CI passing confirms types/lint only, not behavioral correctness. Manual testing is required.
list_event_types_by_username→check_availability_public→ confirmation text in a single turn (2 user messages total)catchblocks — theisConflict/isNetworkheuristics rely on substring matching ("409","conflict","fetch","timeout") which may not cover all real API error formatsNotes
apps/chat/lib/agent.tsretryable,suggestion,fallbackSuggestion) are additional return object properties — no schema enforcement, the agent reads them as contextLink to Devin session: https://app.devin.ai/sessions/f0604c789fbb43299f2dc7ba90c4616b
Requested by: @dhairyashiil