Add greeting conversation mode and state management#1868
Conversation
Introduces a new 'greeting' mode with configuration, connector, and interface for robot-user greeting conversations. Adds a state machine provider for managing conversation states and confidence-based transitions. Updates orchestrator, background, and manager logic to support context-aware mode switching and background task interruption. Refactors function schema and IO provider for improved input handling.
There was a problem hiding this comment.
Pull request overview
This PR introduces a greeting conversation mode with state management capabilities to handle multi-stage human-robot interactions. The changes enable the robot to autonomously transition between approaching and greeting modes based on context, while managing conversation states (idle, approaching, engaging, conversing, concluding, finished) with confidence-based decision making.
Changes:
- Added state machine provider for managing greeting conversation lifecycle with confidence-based transitions
- Implemented context-aware mode transitions triggered by user context updates
- Enhanced background task orchestration with proper stop event management and interruptible sleep
- Refactored action parameter handling to support complex JSON objects and enum types
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runtime/multi_mode/manager.py | Added async context transition checking when user context updates |
| src/runtime/multi_mode/hook.py | Updated lifecycle hooks to properly initialize TTS provider with configuration |
| src/runtime/multi_mode/cortex.py | Added orchestrator cleanup and user context reset during mode initialization |
| src/providers/io_provider.py | Added get_input method for retrieving input objects by key |
| src/providers/greeting_conversation_state_provider.py | New state machine provider for managing conversation states and transitions |
| src/llm/function_schemas.py | Refactored action value extraction logic for better parameter handling |
| src/backgrounds/plugins/rf_mapper.py | Changed time.sleep to use interruptible self.sleep method |
| src/backgrounds/plugins/approaching_mock.py | New mock background task simulating approach detection |
| src/backgrounds/plugins/agent_teleops_status.py | Changed time.sleep to use interruptible self.sleep method |
| src/backgrounds/orchestrator.py | Added stop event propagation to background tasks |
| src/backgrounds/base.py | Added stop event support and interruptible sleep mechanism |
| src/actions/orchestrator.py | Enhanced parameter parsing to handle JSON objects and type conversions |
| src/actions/greeting_conversation/interface.py | New interface definition for greeting conversation action |
| src/actions/greeting_conversation/connector/greeting_conversation.py | New connector implementing greeting conversation state management |
| config/greeting.json5 | New configuration file defining approaching and greeting modes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaces print statements with logging in GreetingConversationStateMachineProvider and adds a warning log in ActionOrchestrator when parameters are not found in input type hints. Extends test coverage in test_orchestrator.py to verify LLM result parsing and parameter handling, including type conversions and ignored parameters.
Introduced a stop event mechanism to ActionConnector and Simulator classes, allowing for cooperative interruption of sleep and tick loops. Replaced direct time.sleep calls with a new sleep method that checks for stop signals, and updated orchestrators to set stop events for managed connectors and simulators. This improves graceful shutdown and responsiveness to stop requests across actions and simulators.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Introduce comprehensive tests for sleep and stop event logic in actions, backgrounds, and simulators. These tests cover normal sleep, sleep interrupted by stop events, immediate return when already stopped, and should_stop behavior with and without events.
Comprehensive tests were added for the convert_function_calls_to_actions function, covering various scenarios such as single and multiple parameters, different parameter names, empty and invalid arguments, missing fields, numeric and boolean values, null handling, fallback priorities, exception handling, and complex nested structures.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Introduces Pydantic-based configuration classes for all hook handlers, replacing generic dict configs with strongly-typed models. Updates handler constructors and test cases to use these config models, improving type safety and validation. The create_hook_handler factory now instantiates config models from dicts, and tests are updated for the new structure.
This commit adds comprehensive tests for the ModeManager's context-aware transition logic and context update handling. It covers scenarios for transition triggering, cooldowns, error handling, logging, merging context data, and end-to-end context update flows.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 34 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaced ApproachingMock with ApproachingPerson for approaching mode, updating config and background plugin. Enhanced conversation state transitions in GreetingConversationStateMachineProvider to better handle LLM-driven conclusions and engagement. Improved lifecycle hook parsing to inject API keys, adjusted sleep ticker error handling, and refined TTS duration estimation. Minor logging and test cleanups included.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Added comprehensive unit tests for MoveUnitreeSDKConnector, MoveUnitreeSDKAdvanceConnector, and GreetingConversationStateMachineProvider. These tests cover initialization, movement processing, error handling, and confidence calculation logic, improving test coverage and reliability of the movement and conversation state components.
Introduces an autouse pytest fixture to reset the GreetingConversationStateMachineProvider singleton before and after each test for isolation. Also updates an assertion to expect the CONCLUDING state instead of CONVERSING in the relevant test.
This pull request introduces a new greeting conversation system for the Unitree Go2 robot, including its configuration, interface, and connector logic. It also refactors the base action connector and all action connectors to support interruptible sleep via a stop event, improving responsiveness and graceful shutdown across the codebase.
Greeting Conversation System Implementation
config/greeting.json5that defines modes, transition rules, and system prompts for the robot's greeting and approaching behaviors.GreetingConversationConnectorinsrc/actions/greeting_conversation/connector/greeting_conversation.py, which manages conversation state, integrates ElevenLabs TTS, and updates context when conversations finish.src/actions/greeting_conversation/interface.py, supporting structured input/output and conversation state tracking.Action Connector Refactor for Interruptible Sleep
ActionConnectorinsrc/actions/base.pyto support a thread-safe stop event, with newset_stop_event,should_stop, andsleepmethods, allowing connectors to interrupt sleep when signaled. Alltickmethods now useself.sleepinstead oftime.sleep. [1] [2] [3]tickmethods, improving shutdown responsiveness and consistency. [1] [2] [3] [4] [5] [6] [7] [8] [9]Codebase Cleanup
timefrom files where sleep is now handled by the base connector. [1] [2] [3] [4] [5] [6] [7] [8]