def update_preference( preference_key: str, preference_value: str, tool_context: ToolContext ) -> Dict[str, Any]: """Update or add a user preference to the session state. Args: preference_key: The preference name (e.g., 'favorite_color', 'favorite_food') preference_value: The new preference value tool_context: Automatically injected by ADK Returns: dict: Operation status and updated preferences """ # Get current preferences or initialize empty dict preferences = tool_context.state.get("preferences", {}) # Update the specific preference preferences[preference_key] = preference_value # Save back to state tool_context.state["preferences"] = preferences return { "status": "success", "message": f"Updated {preference_key} to {preference_value}", "updated_preferences": preferences, "updated_at": datetime.now().isoformat() } __ __