- Update driver_message handling: use when driver provides a custom ad (not just >2 emojis)
- Add reply_instruction to about_falzh, search_trips, create_driver_account, add_trip_by_driver tools for better AI response control
- Add _no_trip_reply_instruction helper to prevent narrow retries or false promises
- Update Arabic prompts: driver style flexibility, phone number privacy, FAQ improvements
- Update system prompts to direct unsure feature queries to about_falzh
- Add/update tests for new behaviors
Merge main updates into huggingface-space-deployment
- Fix search_active_trips to properly handle null seats, using 'available_seats.gte.{seats},available_seats.is.null' instead of malformed 'available_seats.is.null,available_seats.gte.{seats}'
- Update list_active_trips to use 'available_seats.is.null,available_seats.gt.0' instead of 'gt(0)'
- Allow null seats in search results (trips without seat info)
- Make seats fields nullable in database (new migration added)
- Update trip_selection to display 'المقاعد: غير متوفرة' when seats are null
- Update test fixtures and handlers to properly handle null seats
This fixes the issue where trips with null seats were showing as '1 of 1' instead of 'المقاعد: غير متوفرة'
fix: display driver phone numbers on separate lines instead of slash-separated
- Detect unregistered drivers (from group trips) who later DM the bot
- Send personalized welcome with their name and explanation of FALSA benefits
- Upgrade user_mode from new_user to driver automatically
- Improve driver phone lookup to handle /-separated numbers
feat: support multiple phone numbers and prevent duplicate customers
- Add support for multiple phone numbers separated by / in driver profiles
- Normalize phone numbers with country code prepending and leading zero stripping
- Prevent duplicate customers by checking phone_number before upserting
- Merge customer records when same phone appears in group vs DM context
- Make remote_jid nullable for unregistered drivers discovered via groups
- Add database migrations for nullable remote_jid and updated RPC
fix: return tool error message when suppressing LLM reply
- Return error message instead of empty string when tool call suppresses reply
- Instruct driver assistant to show exact error in Arabic when trip creation fails
feat: LLM-driven driver message cleanup for phone numbers and names
- Add driver_message parameter to add_trip_by_driver tool schema
- Update system_driver.md prompt to instruct LLM to clean messages
(remove phone numbers, surrounding text, and driver names)
- Update handler to use LLM-provided driver_message
- Add app/utils/phone.py with regex-based phone number detection
- Add tests/test_phone.py with 25 test cases
- Add test_add_trip_by_driver_uses_llm_cleaned_message test
feat: skip optional trip fields and accept natural date expressions
- Replace missing-fields error with sensible defaults (4 seats, price 0)
so drivers can create trips without specifying seats/price
- Update departure_date schema description to instruct AI to convert
natural date expressions (اليوم/بكرة/غدا/يوم الخميس) to YYYY-MM-DD
- Add driver system prompt rule to never ask drivers to rewrite dates
- Add driver message card support (emoji-rich messages used as-is)
- Add tests for new behaviors
route group message extraction through AIOrchestrator for HuggingFace fallback on Groq rate limits
- remove departure_date from update_trip_field enum
- remove departure_date handling in _build_trip_field_update
- update tool descriptions to warn model date is immutable
replace numbered trip list with trip cards for driver delete/modify/list
- initiate_trip_action and check_driver_trips now send format_trip_card
per trip (like passenger search) instead of a numbered text list
- Driver replies to a trip card to delete (bypass LLM) or modify
(set session, route to LLM for update_trip_field)
- Remove delete_trip_by_number / modify_trip_by_number handlers
and their tool schemas (replaced by card reply flow)
- Remove dead interactive list code (_handle_trip_interactive_reply)
- Clean up trip_selection.py: remove unused builders/parsers
- Update list_driver_trips query to include drivers(*)
- create_booking_lead -> select_trip across tools, schemas, handlers, prompts
- booking_leads table -> trip_selections (with migration)
- update Arabic notifications and prompts to reflect 'interest' not 'booking'
- add selection_count to trip cards and summaries
- update README and falsa_info.md to reflect new coordination model
switch to driver immediately if account exists; only ask name on first time
- prompts/system_new_user.md: try switch_to_driver first, only collect
name on error (no account yet)
- prompts/system_passenger.md: same fix — previously told AI to always
ask for name before switching
Auto-detect trip card replies by context_message_id, bypassing AI for reliable trip selection
When a passenger replies to a trip card via WhatsApp's reply feature,
the context_message_id already identifies which trip was selected.
Instead of relying on the LLM to interpret the reply text (which
fails for short replies like '.'), detect the trip card reply
automatically and call create_booking_lead directly.
compress tool descriptions and deduplicate error string
- Add suppress_llm_reply flag to ToolResult (not serialized to LLM)
- search_trips handler now sends a 'choose a card' prompt and sets
suppress_llm_reply=True when trips are found
- Orchestrator returns empty string immediately when flag is set,
avoiding a second LLM call
- Guard conversation service against sending empty replies
- Update system prompt and tool schema to reflect new behavior
- Send each trip as a separate WhatsApp message with trip_id metadata
- Resolve trip_id automatically when customer replies to a trip card
- Store phone_number on customer upsert
- Parse context_message_id and phone_number from inbound messages
- Add get_message_by_whatsapp_id to repository
- Translate driver booking notification to Arabic
- Increase conversation context window to 8 messages
refactor: consolidate and deduplicate prompt files
- system.md becomes the base prompt with shared instructions + operational context (date, day, timezone)
- Mode files (passenger, new_user, driver) now contain only mode-specific instructions
- _system_prompt concatenates base + mode prompt at runtime
- Adds current day (day_name) to operational context