Fix watchdog replay validation for nullable action results#914
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ActionResult model in aworld/core/common.py to use Optional[str] for the error, action_name, tool_name, and tool_call_id fields, ensuring better compatibility with Pydantic v2 validation for null values. It also introduces a new test case in tests/runners/test_post_tool_progress_watchdog.py to verify that the watchdog handles these nullable fields correctly. The review feedback suggests adopting the str | None syntax for consistency with modern Python standards and recommends expanding the test assertions to ensure other core fields like success and is_done are preserved during processing.
| error: Optional[str] = None | ||
| keep: bool = False | ||
| action_name: str = None | ||
| tool_name: str = None | ||
| action_name: Optional[str] = None | ||
| tool_name: Optional[str] = None | ||
| # llm tool call id | ||
| tool_call_id: str = None | ||
| tool_call_id: Optional[str] = None |
There was a problem hiding this comment.
The explicit use of Optional[str] is correct for Pydantic v2 validation when handling serialized payloads that may contain null values. However, for consistency with other parts of the codebase (e.g., line 63), you might consider using the more modern str | None syntax if the project is targeting Python 3.10+.
| assert emitted[0].payload.action_result[0].error is None | ||
| assert emitted[0].payload.action_result[0].tool_name is None | ||
| assert emitted[0].payload.action_result[0].action_name is None | ||
| assert emitted[0].payload.action_result[0].tool_call_id is None |
There was a problem hiding this comment.
Summary
ActionResultstring fields align with watchdog-serialized payloadsensure_action_results()+arm_post_tool_progress_watchdog()replay pathObservation(**payload)from failing onnullaction result fields during watchdog retriesTest Plan