The current implementation of preemptive generation relies on the _generate_reply process of AgentActivity. This poses no problem in pure voice conversation agent scenarios, but if business logic is handled in on_user_turn_completed, llm_node, or tts_node (such as modifying elements on the page), issues may arise. Due to the existence of preemptive generation, similar transcription results may trigger on_user_turn_completed and tts_node multiple times, which can have an erroneous impact on the state machine.
I believe a more reasonable way to implement preemptive generation is to simply call the large model in advance, cache the result, and only go through those node processes when it is confirmed that the preemptive generation data will be used.
The current implementation of preemptive generation relies on the
_generate_replyprocess ofAgentActivity. This poses no problem in pure voice conversation agent scenarios, but if business logic is handled inon_user_turn_completed,llm_node, ortts_node(such as modifying elements on the page), issues may arise. Due to the existence of preemptive generation, similar transcription results may trigger on_user_turn_completed and tts_node multiple times, which can have an erroneous impact on the state machine.I believe a more reasonable way to implement preemptive generation is to simply call the large model in advance, cache the result, and only go through those node processes when it is confirmed that the preemptive generation data will be used.