def _invoke(customer_text: str) -> None: """Submit one customer turn to the graph and retain its latest state.""" graph_input: dict[str, Any] = {"messages": [HumanMessage(content=customer_text)]} if not st.session_state.started: graph_input.update(INITIAL_STATE) graph_input["messages"] = [HumanMessage(content=customer_text)] st.session_state.started = True try: result = st.session_state.graph.invoke(graph_input, config=st.session_state.config) st.session_state.agent_state = result flush_langfuse(st.session_state.handler) except Exception: st.session_state.started = bool(st.session_state.agent_state.get("messages")) st.error("The assistant could not process that request. Please try again.")