agentune icon indicating copy to clipboard operation
agentune copied to clipboard

Establish standardized serialization pattern with cattrs

Open leonidb opened this issue 1 year ago • 2 comments

Currently, we don't have a standardized approach for JSON serialization/deserialization in the project. Additionally, time-related fields use float types with implicit units, creating ambiguity.

From PR #7 discussion:

  • Need to establish a pattern for using cattrs converter with proper hooks
  • duration_seconds: float = 0.0 - the field name suggests seconds but the type doesn't enforce it
  • Return types like "float seconds" are unclear

Solution

1. Establish standardized cattrs serialization pattern

  • Create a serialization/utils package with a module that initializes the converter
  • Add all required hooks for proper JSON serialization/deserialization
  • Establish this as the standard pattern for the project

2. Fix time handling as part of the standardization

  • Replace duration_seconds: float with duration: timedelta
  • Change method return types from float (seconds) to timedelta
  • Add cattrs hooks for proper timedelta serialization
  • Update call sites to use new field names

leonidb avatar Jun 21 '25 14:06 leonidb

@danarmak I think I've fixed some of the issues, so test description is not accurate

leonidb avatar Jul 01 '25 12:07 leonidb

Classes that need to be serializable - Conversation, Outcome/Outcomes, SimulationSessionResult (and all it's content)

leonidb avatar Jul 01 '25 12:07 leonidb