You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Make human-in-the-loop more consistent between graph state and chat history (#550)
## Summary
This PR addresses inconsistencies between the UI display and the agent's
internal LangGraph state during the ticket booking process. Previously,
hardcoded messages spread across the UI, the backend request handlers,
and agent nodes, led to a disjointed UX where chat history, user
prompts, and agent responses could become out of sync, particularly
after a page refresh.
The core of this change is the introduction of a single, internal helper
function (__booking_handler) that centralizes the logic for both
confirming and declining a ticket booking. This refactoring ensures that
all UI components and chat history entries are a direct reflection of
the agent's state.
## Changes
* Created a common `__booking_handler` to manage both booking "accept"
and "decline" actions, eliminating code duplication and streamlining
maintenance.
* Replaced hardcoded UI text for confirmations and responses with
messages sourced directly from the agent's graph state. This guarantees
consistency between what the user sees and the agent's conversational
history.
* The user's choice (e.g., `"Looks good to me. Book it!"`) and the
agent's final response are now reliably added to the user session's chat
history for both success and decline scenarios.
* Added a crucial comment explaining the rationale for injecting the
"decline" message to the langgraph state *before* invoking the agent.
* Removed unnecessary `params` from the request handlers for better code
hygiene.
0 commit comments